dhcp_configure.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: Create the dhcp template
  16. copy:
  17. src: "{{ role_path }}/files/temp_dhcp.template"
  18. dest: "{{ role_path }}/files/dhcp.template"
  19. mode: 0775
  20. tags: install
  21. - name: Configure DHCP routing settings
  22. block:
  23. - name: Add option routers when dns provided
  24. lineinfile:
  25. path: "{{ role_path }}/files/dhcp.template"
  26. insertafter: "^(.*)range dynamic-bootp"
  27. line: "option routers {{ hpc_ip }};"
  28. - name: Add domain name servers when primary dns only provided
  29. lineinfile:
  30. path: "{{ role_path }}/files/dhcp.template"
  31. insertafter: "^(.*)range dynamic-bootp"
  32. line: "option domain-name-servers {{ primary_dns }};"
  33. when: secondary_dns | length < 1
  34. - name: Add domain name servers when primary and secondary dns provided
  35. lineinfile:
  36. path: "{{ role_path }}/files/dhcp.template"
  37. insertafter: "^(.*)range dynamic-bootp"
  38. line: "option domain-name-servers {{ primary_dns }}, {{ secondary_dns }};"
  39. when: secondary_dns | length > 1
  40. when: primary_dns | length > 1
  41. - name: Assign subnet and netmask
  42. replace:
  43. path: "{{ role_path }}/files/dhcp.template"
  44. regexp: '^subnet subnet_mask netmask net_mask {'
  45. replace: 'subnet {{ subnet }} netmask {{ netmask }} {'
  46. tags: install
  47. - name: Assign netmask
  48. replace:
  49. path: "{{ role_path }}/files/dhcp.template"
  50. regexp: '^option subnet-mask net_mask;'
  51. replace: 'option subnet-mask {{ netmask }};'
  52. - name: Assign default lease time
  53. replace:
  54. path: "{{ role_path }}/files/dhcp.template"
  55. regexp: '^default-lease-time default;'
  56. replace: 'default-lease-time {{ default_lease_time }};'
  57. - name: Assign max lease time
  58. replace:
  59. path: "{{ role_path }}/files/dhcp.template"
  60. regexp: '^max-lease-time max;'
  61. replace: 'max-lease-time {{ max_lease_time }};'
  62. - name: Assign DHCP range
  63. replace:
  64. path: "{{ role_path }}/files/dhcp.template"
  65. regexp: '^range dynamic-bootp start end;'
  66. replace: 'range dynamic-bootp {{ host_network_dhcp_start_range }} {{ host_network_dhcp_end_range }};'
  67. - name: Create the cobbler settings file
  68. copy:
  69. src: "{{ role_path }}/files/cobbler_settings"
  70. dest: "{{ role_path }}/files/settings.yaml"
  71. mode: 0775
  72. tags: install
  73. - name: Assign server ip
  74. replace:
  75. path: "{{ role_path }}/files/settings.yaml"
  76. regexp: '^server: 127.0.0.1'
  77. replace: 'server: {{ hpc_ip }}'
  78. - name: Assign next server ip
  79. replace:
  80. path: "{{ role_path }}/files/settings.yaml"
  81. regexp: '^next_server: 127.0.0.1'
  82. replace: 'next_server: {{ hpc_ip }}'
  83. - name: Assign proxy_url_ext url
  84. replace:
  85. path: "{{ role_path }}/files/settings.yaml"
  86. regexp: '^proxy_url_ext: "http://ip:port"'
  87. replace: 'proxy_url_ext: "http://{{ hpc_ip }}:{{ http_port }}"'
  88. - name: Set the server_args for {{ provision_os }} in tftp file
  89. replace:
  90. path: "{{ role_path }}/files/tftp"
  91. regexp: '^ server_args = -s /srv/tftpboot'
  92. replace: ' server_args = -s /var/lib/tftpboot'
  93. when:
  94. - mgmt_os == os_supported_rocky
  95. - name: Set the parameters for {{ provision_os }}
  96. block:
  97. - name: Set the tftpboot_location for {{ provision_os }}
  98. replace:
  99. path: "{{ role_path }}/files/settings.yaml"
  100. regexp: '^tftpboot_location: "/var/lib/tftpboot"'
  101. replace: 'tftpboot_location: "/srv/tftpboot"'
  102. - name: Set the webdir for {{ provision_os }}
  103. replace:
  104. path: "{{ role_path }}/files/settings.yaml"
  105. regexp: '^webdir: "/var/www/cobbler"'
  106. replace: 'webdir: "/srv/www/cobbler"'
  107. - name: Set the server_args for {{ provision_os }} in tftp file
  108. replace:
  109. path: "{{ role_path }}/files/tftp"
  110. regexp: '^ server_args = -s /var/lib/tftpboot'
  111. replace: ' server_args = -s /srv/tftpboot'
  112. when: os_supported_leap in mgmt_os