DevOps Classroom Series – 26/Dec/2020

Solving the Scenario

  • Exercise: Now try Writing an ansible playbook for install tomcat8 on ubuntu and centos
  • Solution:
  • We have configured 3 ansible nodes
    • 2 centos server with python 2.7
    • 1 ubuntu server with python 3.7
  • All the machines have a user ‘ansible’ configured for password less authentication
  • So first lets verify inventory Refer Here
  • We have ran ansible ping adhoc command Preview
  • ansible has predefined inventory parameters which can change ansible behavior for a node or group of nodes
    • ansible_host: This is DNS name
    • ansible_port: port for ssh (default will be 22)
    • ansible_user: Specifies the username that ansible will connect to node with
    • ansible_ssh_private_key_file: SSH private key file used to connect to node
    • ansible_python_interpreter: used to set manual path of python on node
    • ansible_become
    • ansible_become_method
    • ansible_sudo_pass
    • ansible_become_password
    • ansible_connection
    • ansible_shell_type
    • ansible_shell_executable
    • ansible_ssh_pass
  • Refer Here
  • To find some details about nodes we can use the setup module Refer Here
  • We can combine facts with ansible conditionals for conditional execution Refer Here
  • Refer Here for the changeset Preview
  • Now lets try to create a user as mentioned below
sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat
  • Refer Here for the changeset
  • Refer Here for the draft playbook with 3 steps of ubuntu automated
  • Refer Here for the draft playbook with 3 steps for centos automated
  • Exercise:
    • Correct the failures in playbook execution
    • Try creating only one playbook which does this 3 steps automation in centos and ubuntu
    • Observe the behavior of your playbook when it is executed multiple times

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube