install_ipa_server.yml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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: Include common vars
  16. include_vars: ../../login_common/vars/main.yml
  17. - name: Fetch hostname
  18. command: hostname
  19. register: new_serv_hostname
  20. changed_when: false
  21. - name: Set fact for server hostname
  22. set_fact:
  23. server_hostname: "{{ new_serv_hostname.stdout }}"
  24. - name: Uninstall server if it is already installed
  25. command: ipa-server-install --uninstall -U
  26. changed_when: false
  27. failed_when: false
  28. - block:
  29. - name: Install ipa server in CentOS 7.9
  30. command: >-
  31. ipa-server-install -n '{{ hostvars['127.0.0.1']['domain_name'] }}' --hostname='{{ server_hostname }}' -a '{{ hostvars['127.0.0.1']['kerberos_admin_password'] }}'
  32. -p '{{ hostvars['127.0.0.1']['directory_manager_password'] }}' -r '{{ hostvars['127.0.0.1']['realm_name'] }}' --setup-dns --auto-forwarders --auto-reverse -U
  33. changed_when: true
  34. no_log: true
  35. register: install_ipa_server
  36. when:
  37. - ( ansible_distribution | lower == os_centos )
  38. - ( ansible_distribution_version < os_version )
  39. - name: Install ipa server in CentOS > 8 or Rocky 8
  40. command: >-
  41. ipa-server-install -n '{{ hostvars['127.0.0.1']['domain_name'] }}' --hostname='{{ server_hostname }}' -a '{{ hostvars['127.0.0.1']['kerberos_admin_password'] }}'
  42. -p '{{ hostvars['127.0.0.1']['directory_manager_password'] }}' -r '{{ hostvars['127.0.0.1']['realm_name'] }}' --setup-dns --no-forwarders --no-reverse --no-ntp -U
  43. changed_when: true
  44. no_log: true
  45. register: install_ipa_server
  46. when:
  47. - ( ansible_distribution | lower == os_centos ) or
  48. ( ansible_distribution | lower == os_rocky )
  49. - ( ansible_distribution_version >= os_version )
  50. rescue:
  51. - name: Install ipa server failed
  52. fail:
  53. msg: "Error: {{ install_ipa_server.stderr_lines }}"
  54. - block:
  55. - name: Authenticate as admin
  56. shell: set -o pipefail && echo $'{{ hostvars['127.0.0.1']['kerberos_admin_password'] }}' | kinit admin
  57. no_log: true
  58. changed_when: false
  59. register: authenticate_admin
  60. rescue:
  61. - name: Authenticate as admin failed
  62. fail:
  63. msg: "Error: {{ authenticate_admin.stderr }}"
  64. - name: Replace the /etc/resolv.conf file
  65. copy:
  66. src: "{{ temp_resolv_conf_path }}"
  67. dest: "{{ resolv_conf_path }}"
  68. mode: "{{ file_mode }}"
  69. remote_src: yes