install_ipa_server.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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: Fetch hostname
  16. command: hostname
  17. register: new_serv_hostname
  18. changed_when: false
  19. - name: Set fact for server hostname
  20. set_fact:
  21. server_hostname_ms: "{{ new_serv_hostname.stdout }}"
  22. - name: Save the hostname
  23. copy:
  24. dest: "{{ server_file }}"
  25. content: |
  26. ipaddress: "{{ hostvars['localhost']['ansible_default_ipv4']['address'] }}"
  27. server_hostname: "{{ server_hostname_ms }}"
  28. server_domain: "{{ domain_name }}"
  29. owner: root
  30. mode: "{{ file_mode }}"
  31. - name: Uninstall server if it is already installed
  32. command: ipa-server-install --uninstall -U
  33. changed_when: false
  34. failed_when: false
  35. - name: Install ipa server in CentOS > 8 or Rocky 8.4
  36. command: >-
  37. ipa-server-install -n '{{ domain_name }}' --hostname='{{ server_hostname_ms }}' -a '{{ ipa_admin_password }}'
  38. -p '{{ directory_manager_password }}' -r '{{ realm_name }}' --setup-dns --no-forwarders --no-reverse --no-ntp -U
  39. changed_when: true
  40. no_log: true
  41. when:
  42. - ( ansible_distribution | lower == os_centos ) or
  43. ( ansible_distribution | lower == os_rocky )
  44. - ( ansible_distribution_version >= os_version )
  45. - name: Authenticate as admin
  46. shell: set -o pipefail && echo $'{{ ipa_admin_password }}' | kinit admin
  47. no_log: true
  48. changed_when: false
  49. - name: Replace the /etc/resolv.conf file
  50. copy:
  51. src: "{{ temp_resolv_conf_path }}"
  52. dest: "{{ resolv_conf_path }}"
  53. mode: "{{ file_mode }}"
  54. remote_src: yes