mngmnt_container_configure.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Copyright 2021 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: Initial setup
  16. hosts: localhost
  17. connection: local
  18. gather_facts: false
  19. tasks:
  20. - name: Change mode of tftpboot
  21. file:
  22. path: /var/lib/tftpboot
  23. mode: 0777
  24. - name: Link for tftp services
  25. shell: cp -v /usr/lib/systemd/system/tftp.service /etc/systemd/system/tftp-server.service
  26. - name: Link for tftp services
  27. shell: cp -v /usr/lib/systemd/system/tftp.socket /etc/systemd/system/tftp-server.socket
  28. - name: Edit the tftp-server service file
  29. replace:
  30. path: /etc/systemd/system/tftp-server.service
  31. regexp: ^Requires=tftp.socket
  32. replace: Requires=tftp-server.socket
  33. - name: Edit the tftp-server service file
  34. replace:
  35. path: /etc/systemd/system/tftp-server.service
  36. regexp: ^ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot
  37. replace: ExecStart=/usr/sbin/in.tftpd -c -p -s /var/lib/tftpboot
  38. - name: Edit the tftp-server service file
  39. replace:
  40. path: /etc/systemd/system/tftp-server.service
  41. regexp: ^Also=tftp.socket
  42. replace: Also=tftp.socket
  43. - name: Edit the tftp-server service file
  44. lineinfile:
  45. path: /etc/systemd/system/tftp-server.service
  46. insertafter: '^[Install]'
  47. line: 'WantedBy=multi-user.target'
  48. - name: Edit the tftp-server socket file
  49. lineinfile:
  50. path: /etc/systemd/system/tftp-server.socket
  51. line: "BindIPv6Only=both"
  52. insertafter: [Socket]
  53. - name: Start tftp services
  54. service:
  55. name: tftp-server
  56. state: started
  57. - name: Start dhcpd services
  58. service:
  59. name: dhcpd
  60. state: started
  61. - name: Fetch ansible-playbook location
  62. command: whereis ansible-playbook
  63. changed_when: false
  64. register: ansible_playbook_location
  65. - name: Add inventory cron job
  66. cron:
  67. name: Create inventory
  68. minute: "*/5"
  69. job: "{{ ansible_playbook_location.stdout.split(' ')[1] }} /root/inventory_creation.yml"