tftp.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: Start tftp and dhcp
  16. hosts: localhost
  17. connection: local
  18. gather_facts: true
  19. tasks:
  20. - name: Configure tftp for leap
  21. block:
  22. - name: Stop the tftp.socket
  23. command: systemctl stop tftp.socket
  24. - name: Modify tftp.socket to listsen on IPv4
  25. replace:
  26. path: "/usr/lib/systemd/system/tftp.socket"
  27. regexp: 'ListenDatagram=69'
  28. replace: 'ListenDatagram=0.0.0.0:69'
  29. - name: Reload the configurations
  30. command: systemctl daemon-reload
  31. - name: Enable tftp.socket
  32. command: systemctl enable tftp.socket
  33. - name: Start tftp.socket
  34. command: systemctl start tftp.socket
  35. when: ("leap" in ansible_facts['distribution'] | lower)
  36. - name: Fetch tftp status
  37. command: systemctl is-active tftp
  38. args:
  39. warn: no
  40. register: tftp_status
  41. ignore_errors: yes
  42. changed_when: false
  43. - name: Start tftp if inactive state
  44. command: systemctl start tftp.service
  45. args:
  46. warn: no
  47. when: "('inactive' in tftp_status.stdout) or ('unknown' in tftp_status.stdout)"
  48. - name: Fetch dhcp status
  49. command: systemctl is-active dhcpd
  50. args:
  51. warn: no
  52. register: dhcp_status
  53. ignore_errors: yes
  54. changed_when: false
  55. - name: Start dhcp if inactive state
  56. command: systemctl start dhcpd.service
  57. args:
  58. warn: no
  59. when: "('inactive' in dhcp_status.stdout) or ('unknown' in dhcp_status.stdout)"