tftp.yml 2.1 KB

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