install_ipa_client.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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: loginnode_hostname
  18. changed_when: false
  19. - name: Install freeipa client package
  20. package:
  21. name: "{{ ipa_client_package }}"
  22. state: present
  23. tags: install
  24. - name: Set hostname of ipa server when manager node has ipa server installed
  25. set_fact:
  26. required_ipa_admin_pwd: "{{ hostvars['127.0.0.1']['kerberos_admin_password'] }}"
  27. required_server_hostname: "{{ hostvars[groups['manager'][0]]['server_hostname'] }}"
  28. required_domain_name: "{{ hostvars['127.0.0.1']['domain_name'] }}"
  29. when: not hostvars['127.0.0.1']['ipa_server_ms']
  30. no_log: true
  31. - name: Set hostname of ipa server when MS has ipa server installed
  32. set_fact:
  33. required_ipa_admin_pwd: "{{ hostvars['127.0.0.1']['ms_ipa_admin_password'] }}"
  34. required_server_hostname: "{{ hostvars['127.0.0.1']['server_hostname'] }}"
  35. required_domain_name: "{{ hostvars['127.0.0.1']['server_domain'] }}"
  36. ms_ip_address: "{{ hostvars['127.0.0.1']['ipaddress'] }}"
  37. when: hostvars['127.0.0.1']['ipa_server_ms']
  38. no_log: true
  39. - name: Add host name in hosts file
  40. lineinfile:
  41. dest: "{{ hosts_file_dest }}"
  42. line: "{{ ms_ip_address }} {{ required_server_hostname }}"
  43. state: present
  44. create: yes
  45. mode: "{{ hosts_file_mode }}"
  46. when: hostvars['127.0.0.1']['ipa_server_ms']
  47. - name: Uninstall client if already installed
  48. command: ipa-client-install --uninstall -U
  49. changed_when: false
  50. failed_when: false
  51. - block:
  52. - name: Install ipa client in CentOS 7.9
  53. command: >-
  54. ipa-client-install --domain '{{ required_domain_name }}' --server '{{ required_server_hostname }}'
  55. --principal admin --password '{{ required_ipa_admin_pwd }}' --force-join --enable-dns-updates --force-ntpd -U
  56. changed_when: true
  57. no_log: true
  58. register: install_ipa_client
  59. when:
  60. - ( ansible_distribution | lower == os_centos )
  61. - ( ansible_distribution_version < os_version )
  62. - name: Install ipa client in Rocky 8
  63. command: >-
  64. ipa-client-install --domain '{{ required_domain_name }}' --server '{{ required_server_hostname }}'
  65. --principal admin --password '{{ required_ipa_admin_pwd }}' --force-join --enable-dns-updates --no-ntp -U
  66. changed_when: true
  67. no_log: true
  68. register: install_ipa_client
  69. when:
  70. - ( ansible_distribution | lower == os_centos ) or
  71. ( ansible_distribution | lower == os_rocky )
  72. - ( ansible_distribution_version >= os_version )
  73. rescue:
  74. - name: Install ipa client failed
  75. fail:
  76. msg: "Error: {{ install_ipa_client.stderr_lines }}"