Skip to content

Commit

Permalink
ipa client installation tool
Browse files Browse the repository at this point in the history
Signed-off-by: abhishek-sa1 <[email protected]>
  • Loading branch information
abhishek-sa1 committed Jul 26, 2022
1 parent 6ad5fd1 commit 0c8b8c5
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 2 deletions.
4 changes: 2 additions & 2 deletions roles/login_node/tasks/install_ipa_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
- name: Install ipa client in CentOS 7.9(It may take 5-10 mins)
command: >-
ipa-client-install --domain '{{ required_domain_name }}' --server '{{ required_server_hostname }}'
--principal admin --password '{{ required_ipa_admin_pwd }}' --force-join --enable-dns-updates --force-ntpd -U
--principal admin --password '{{ required_ipa_admin_pwd }}' --force-join --enable-dns-updates --force-ntpd --mkhomedir -U
changed_when: true
no_log: true
register: install_ipa_client
Expand All @@ -85,7 +85,7 @@
- name: Install ipa client in RHEL 8 or Rocky 8(It may take 5-10 mins)
command: >-
ipa-client-install --domain '{{ required_domain_name }}' --server '{{ required_server_hostname }}'
--principal admin --password '{{ required_ipa_admin_pwd }}' --force-join --enable-dns-updates --no-ntp -U
--principal admin --password '{{ required_ipa_admin_pwd }}' --force-join --enable-dns-updates --no-ntp --mkhomedir -U
changed_when: true
no_log: true
register: install_ipa_client
Expand Down
140 changes: 140 additions & 0 deletions tools/install_ipa_client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

# This playbook is used to install FreeIPA clients in nodes
# Input approrpriate values in below command
# Command to execute: ansible-playbook install_ipa_client.yml -i inventory -e kerberos_admin_password="" -e ipa_server_hostname="" -e domain_name="" -e ipa_server_ipadress=""

- name: Install IPA client in nodes
hosts: all
gather_facts: yes
vars:
nfs_node_group_fail_msg: "nfs_node group should be present in inventory and contain exactly 1 node"
nfs_node_group_success_msg: "nfs_node group check passed"
success_validation_msg: 'Validated all required input parameters'
fail_validation_msg: 'Missing input parameters. Provide all required input parameters. Command to execute: ansible-playbook install_ipa_client.yml -i inventory -e kerberos_admin_password="" -e ipa_server_hostname="" -e domain_name="" -e ipa_server_ipadress=""'
tasks:
- name: Verify all paramaters are provided
assert:
that:
- kerberos_admin_password is defined
- ipa_server_hostname is defined
- domain_name is defined
- ipa_server_ipadress is defined
- kerberos_admin_password | length > 1
- ipa_server_hostname | length > 1
- domain_name | length > 1
- ipa_server_ipadress | length > 1
success_msg: "{{ success_validation_msg }}"
fail_msg: "{{ fail_validation_msg }}"

- name: Execute hostname_validation role
include_role:
name: "{{ playbook_dir }}/../roles/hostname_validation"
tasks_from: validate_hostname

- name: Add ports of manager and login node to firewall
include_role:
name: "{{ playbook_dir }}/../roles/login_common"
tasks_from: firewall_settings

- name: Enable module idm in Rocky or Centos >= 8.0
include_role:
name: "{{ playbook_dir }}/../roles/login_common"
tasks_from: enable_dnf_module

- name: Update Packages
include_role:
name: "{{ playbook_dir }}/../roles/login_common"
tasks_from: update_package

- name: Enable user home directory creation
include_role:
name: "{{ playbook_dir }}/../roles/login_common"
tasks_from: enable_home_dir_creation

- name: Include login_node vars
include_vars: "{{ playbook_dir }}/../roles/login_node/vars/main.yml"

- name: Include login_common vars
include_vars: "{{ playbook_dir }}/../roles/login_common/vars/main.yml"

- name: Execute firewall_settings from login_node role
include_role:
name: "{{ playbook_dir }}/../roles/login_node"
tasks_from: firewall_settings

- name: Install DL1 - client(It may take 5-10 mins)
command: yum module install idm:DL1/client -y
changed_when: true
failed_when: false
args:
warn: false
when: ansible_distribution | lower == os_redhat

- name: Install freeipa client package
package:
name: "{{ ipa_client_package }}"
state: present

- name: Delete the cert_path
command: rm -rf {{ cert_path }}
changed_when: false
failed_when: false
args:
warn: false
when: ansible_distribution | lower == os_redhat

- name: Add host name in hosts file
lineinfile:
dest: "{{ hosts_file_dest }}"
line: "{{ ipa_server_ipadress }} {{ ipa_server_hostname }}"
state: present
create: yes
mode: "{{ hosts_file_mode }}"

- name: Uninstall client if already installed
command: ipa-client-install --uninstall -U
changed_when: false
failed_when: false

- block:
- name: Install ipa client in CentOS 7.9(It may take 5-10 mins)
command: >-
ipa-client-install --domain '{{ required_domain_name }}' --server '{{ required_server_hostname }}'
--principal admin --password '{{ required_ipa_admin_pwd }}' --force-join --enable-dns-updates --force-ntpd --mkhomedir -U
changed_when: true
no_log: true
register: install_ipa_client
when:
- ( ansible_distribution | lower == os_centos )
- ( ansible_distribution_version < os_version )

- name: Install ipa client in RHEL 8 or Rocky 8(It may take 5-10 mins)
command: >-
ipa-client-install --domain '{{ domain_name }}' --server '{{ ipa_server_hostname }}'
--principal admin --password '{{ kerberos_admin_password }}' --force-join --enable-dns-updates --no-ntp --mkhomedir -U
changed_when: true
no_log: true
register: install_ipa_client
when:
- ( ansible_distribution | lower == os_centos ) or
( ansible_distribution | lower == os_rocky ) or
( ansible_distribution | lower == os_redhat )
- ( ansible_distribution_version >= os_version )
rescue:
- name: Install ipa client failed
fail:
msg: "Error: {{ install_ipa_client.stderr_lines }}"

0 comments on commit 0c8b8c5

Please sign in to comment.