PROVE IT !!If you know it then PROVE IT !! Skill Proficiency Test

How-to: Automate the Systems Security Services Daemon Installation and Troubleshoot it with Ansible – Part 2

Background

We summarized the technical details about the Systems Security Services Daemon’s configuration and installation in the previous blog post: Best Practices Guide for Systems Security Services Daemon Configuration and Installation (Part 1). 

Manual installation, configuration, and troubleshooting can be exceptionally time consuming and run the risk of inconsistencies because work needs be replicated individually on each host. This leaves us with one final question: How can these tasks be automated on all hosts?

One possible solution is Ansible [1]. It is a widely-used and accepted automation tool, which is part of the Red Hat distribution, and it provides integration with several Red Hat tools. It uses OpenSSH for transport. Ansible needs an inventory file that contains all managed hosts. This file can be either static or dynamically generated. We recommend applying an Ansible playbook for SSSD installation and configuration, and using Ansible ad-hoc commands for troubleshooting any possible issues. 

Dynamic Inventory Script for Cloudera Manager

To make integration easier, Gabor Roczei created a dynamic inventory script that allows Ansible to gather data from Cloudera Manager. Its main advantages are:

  • Cache management of inventory for better performance
  • Cloudera Manager’s HTTP cookie handling   
  • Support for multiple Cloudera Manager instances
  • SSL-friendly, as the root CA check of the Cloudera Manager server can be disabled or enabled
Ansible dynamic inventory vs. Cloudera Managers

Figure 1: High level architecture of Ansible dynamic inventory vs. Cloudera Managers

Configuration

Step 1: Configuration of the related Cloudera Manager(s):

Other optional configuration parameters:

Note: We recommend adding these environment variables to the startup file of your shell. For example: $HOME/.bashrc

Step 2: Installation of the git package:

Step 3: Installation of the Ansible package:

Step 4: Clone the cloudera-playbook git repository [2]:

Note: The cloudera-playbook git repository is not officially supported by Cloudera, but the authors recommend using it.

Step 5: Set up the default Ansible inventory and other useful Ansible parameters [3]:

Note: Update the inventory path of the dynamic_inventory_cm if necessary

Step 6: Change the working directory to cloudera-playbook:

Step 7: The available Cloudera Manager clusters (Ansible groups, such as Cluster_1, Balaton) can be listed with the following command:

Note: The cache of the Cloudera Manager inventory can be refreshed with the following command:

Step 8: Setup the SSH public key authentication for remote hosts [4]:

The big advantage of this is that with ad-hoc commands, you do not need to enter your password each time you run the command, only the first time you enter the private key password.

If the ~/.ssh/id_rsa.pub and ~/.ssh/id_rsa files do not exist, they need to be generated with the ssh-keygen command prior to connecting to the managed hosts.

Launch a subshell with the following command: 

You will execute the rest of the commands in this How-To article in the subshell. 

Add the SSH private key into the SSH authentication agent: 

Validate:

Upload the SSH public key (id_rsa.pub) to the managed hosts:

For example, you can use the root user:

Note: If you do not want to use SSH public key authentication, add the –ask-pass parameter each time you run the Ansible command. 

Step 9: Test remote host connectivity (optional):

For example, you can execute the command with the root user:

Step 10: The ad-hoc command feature enables running single and arbitrary Linux commands on all hosts. You can use this to troubleshoot slow group resolution issues. 

The following commands are example ad-hoc commands where Balaton is a group of hosts that is a cluster in Cloudera Manager: 

The following example uses the root user:

Further information about dynamic inventory and ad-hoc commands can be found in the Ansible documentation:

  1. Developing Dynamic Inventory [5]
  2. Documentation of Ansible Ad-Hoc commands [6]

SSSD Setup with Ansible (Applicable for RHEL 7 / CentOS 7)

Step 1: Edit the default variables in group_vars/all:

Step 2: Enable Kerberos on the hosts:

If necessary, update this template file (See the Ansible Templating (Jinja2) [7] documentation for more information):

Run this command to apply it on the managed hosts:

Step 3: Join the host(s) to realm:

If necessary, update these template files (See the Ansible Templating (Jinja2) [7] documentation for more information):

Note: All of the main parameters in these templates have been explained in the previous SSSD blog article.

Run this command to apply it on all managed hosts:

Run this command to apply it on a cluster (for example: Balaton) (See the Ansible Best Practices [8] documentation for more information):

Remove all hosts from the realm with this command: 

Remove the Balaton hosts from the realm with this command (See the Ansible Best Practices [8] documentation for more information): 

Conclusions

The article demonstrated the power of Ansible, which streamlines the management of a large number of hosts. The SSSD installation and configuration provides an example of how multiple hosts can be managed in conjunction. It also enables faster troubleshooting of issues because no direct login is required for individual hosts. 

Acknowledgments 

This blog post was done in collaboration with many Clouderans. We would like to thank all the people who were involved, including Gabor Roczei, Matyas Orhidi, Gergely Tomka, Laszlo Stuber, Mubashir Kazia, Manish Maheshwari, Todd Grayson, Gabor Gyulai, Janos Kovacs, Tristan Stevens, Niel Dunnage, Manoj Shanmugasundaram, Georg Zigldrum, Alexandru Anghel, Gergely Nagy, Tom Wheeler, Coral Waters and Shelby Khan.

References

  1. https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html 
  2. https://github.com/cloudera/cloudera-playbook
  3. https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg
  4. https://docs.ansible.com/ansible/latest/modules/authorized_key_module.html
  5. https://docs.ansible.com/ansible/latest/dev_guide/developing_inventory.html
  6. http://docs.ansible.com/ansible/latest/intro_adhoc.html
  7. https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html
  8. https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html

Facebooktwittergoogle_pluslinkedinmailFacebooktwittergoogle_pluslinkedinmail

Let’s block ads! (Why?)