restrict_nonessentials.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Gathering service facts
  16. service_facts:
  17. - name: Disable bluetooth services
  18. block:
  19. - name: Disabling bluetooth service
  20. service:
  21. name: bluetooth
  22. enabled: no
  23. state: stopped
  24. when:
  25. - "'bluetooth.service' in ansible_facts.services"
  26. - ansible_facts.services['bluetooth.service'].status in service_status
  27. - name: Disabling bluez service
  28. service:
  29. name: dbus-org.bluez.service
  30. enabled: no
  31. state: stopped
  32. failed_when: false
  33. when:
  34. - "'dbus-org.bluez.service' in ansible_facts.services"
  35. - ansible_facts.services['dbus-org.bluez.service'].status in service_status
  36. - name: Disabling blueman service
  37. systemd:
  38. name: blueman-mechanism.service
  39. state: stopped
  40. enabled: no
  41. when:
  42. - "'blueman-mechanism.service' in ansible_facts.services"
  43. - ansible_facts.services['blueman-mechanism.service'].status in service_status
  44. when: "'bluetooth' in disable_services"
  45. - name: Disabling telnet service
  46. service:
  47. name: telnet.socket
  48. enabled: no
  49. state: stopped
  50. when:
  51. - "'telnet' in disable_services"
  52. - "'telnet@.service' in ansible_facts.services"
  53. - ansible_facts.services['telnet@.service'].status in service_status
  54. - name: Disabling lpd service
  55. service:
  56. name: cups-lpd.socket
  57. enabled: no
  58. state: stopped
  59. when:
  60. - "'lpd' in disable_services"
  61. - "'cups-lpd@.service' in ansible_facts.services"
  62. - ansible_facts.services['cups-lpd@.service'].status in service_status
  63. - name: Disabling rlogin service
  64. service:
  65. name: rlogin.socket
  66. enabled: no
  67. state: stopped
  68. when:
  69. - "'rlogin' in disable_services"
  70. - "'rlogin.socket' in ansible_facts.services"
  71. - ansible_facts.services['rlogin.socket'].status in service_status
  72. - name: Disabling rexec service
  73. service:
  74. name: rexec.socket
  75. enabled: no
  76. state: stopped
  77. changed_when: false
  78. when:
  79. - "'rexec' in disable_services"
  80. - "'rexec.socket' in ansible_facts.services"
  81. - ansible_facts.services['rexec.socket'].status in service_status