install_ipa_server.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. - name: Install ipa server in CentOS 7.9
  29. command: >-
  30. ipa-server-install -n '{{ hostvars['127.0.0.1']['domain_name'] }}' --hostname='{{ server_hostname }}' -a '{{ hostvars['127.0.0.1']['ipa_admin_password'] }}'
  31. -p '{{ hostvars['127.0.0.1']['directory_manager_password'] }}' -r '{{ hostvars['127.0.0.1']['realm_name'] }}' --setup-dns --auto-forwarders --auto-reverse -U
  32. changed_when: true
  33. no_log: true
  34. when:
  35. - ( ansible_distribution | lower == os_centos )
  36. - ( ansible_distribution_version < os_version )
  37. - name: Install ipa server in CentOS > 8 or Rocky 8.4
  38. command: >-
  39. ipa-server-install -n '{{ hostvars['127.0.0.1']['domain_name'] }}' --hostname='{{ server_hostname }}' -a '{{ hostvars['127.0.0.1']['ipa_admin_password'] }}'
  40. -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
  41. changed_when: true
  42. no_log: true
  43. when:
  44. - ( ansible_distribution | lower == os_centos ) or
  45. ( ansible_distribution | lower == os_rocky )
  46. - ( ansible_distribution_version >= os_version )
  47. - name: Authenticate as admin
  48. shell: set -o pipefail && echo $'{{ hostvars['127.0.0.1']['ipa_admin_password'] }}' | kinit admin
  49. no_log: true
  50. changed_when: false
  51. - name: Replace the /etc/resolv.conf file
  52. copy:
  53. src: "{{ temp_resolv_conf_path }}"
  54. dest: "{{ resolv_conf_path }}"
  55. mode: "{{ file_mode }}"
  56. remote_src: yes