DevOps Classroom notes 25/Feb/2024

Ansible contd

Ansible Facts

  • Facts are collected by ansible during playbook execution by default.
  • This pull information about the node on which execution is happending
  • Ansible has a module called setup which can pull facts. Refer Here for facts & Refer Here for setup.

Ansible conditionals

  • We can execute a task based on condition using when Refer Here

Ansible variables

  • Ansible allows to define variables and use them in playbook.
  • First location where we will be adding variables is in inventory
  • Refer Here for official docs

Ansible modules

Lets change the Activity 1 to use conditionals and facts

  • Refer Here for the changes done.
  • Refer Here for the changes done to remove duplicate tasks
  • Using generic modules for package Refer Here for the changes done.
  • Lets run this playbook only when os family is Debian or RedHat by using the fail module Refer Here
  • Refer Here for the changes done to fail playbook execution on unsupported os families

Exercise

  • Ensure you have one ansible control node and one node
  • ansible control node:
    • ubuntu 22.04
  • node:
    • ubuntu 20.04
  • Configure ansible by ensuring the common user name with sudo permissions is ansible

Waiting for setup till 9:35 AM

  • Write a playbook to install git, tree, net-tools on both node and then adopt to run on ansible control node.

Wait till 9:55 AM

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Exit mobile version
%%footer%%