DevOps Classroomnotes 10/Apr/2022

Ansible-Controlling playbook execution

  • Forks:
    • Maximum number of simultaneous connections Ansible made on each Task
    • How to set it:
      • /etc/ansible/ansible.cfg
        [defaults]
        forks = 100
      • ansible-playbook -f 100 my_playbook.yml
        Preview
  • Strategy:
    • Types
      • linear
      • free
      • debug
    • How to set strategy
      • In playbook
        “`yaml
      • <li>hosts: all
        become: yes
        strategy: free
        “`

      • /etc/ansible/ansible.cfg
        [defaults]
        strategy = free

        Preview

Keywords that effect ansible playbook execution

  • serial:

    • if you want to manage only few machines at a time.
    • You can define how many hosts Ansible should manage at a single time by using the serial keywork
      “`yaml
    • </ul>
      <hr />
      <ul>
      <li>name: test
      hosts: all
      serial: 2
      gather_facts: no
      tasks:<ul>
      <li>name: first task
      debug:
      msg: "first task"</li>
      <li>name: second task
      debug:
      msg: "second task"
      “`

  • Let assume we have 4 nodes
    “`
    PLAY [all] ##################################</li>
    </ul>
    TASK [ first task] ##########################
    changed [web1]
    changed [web2]
    TASK [ second task] ##########################
    changed [web1]
    changed [web2]
    PLAY [all] ##################################
    TASK [ first task] ##########################
    changed [web3]
    changed [web4]
    TASK [ second task] ##########################
    changed [web3]
    changed [web4]
    “`
    * throttle: sets number of workers for a particular task. This can be set at block or task.
    * run_once: Runs only one node in the inventory
    * ignore_errors: ignores all the errors occured during playbook execution
    * ignore_unreachable: ignores unreachable nodes
    * order: Order in which nodes from inventory are picked
    Preview

Ansible Tower Installation

  • Refer Here
  • For ansible tower installation and usage please refer classroom video

Ansible Vault

  • Ansible Vault helps secure vital secret information.
  • Ansible vault can encrypt variables or even entire files and YAML Playbooks
  • Create an encrypted file in Ansible
    • Create a file with username: tomcat and password: tomcat in yaml
      Preview
  • view the encrypted file
    Preview
  • edit the content
    Preview
  • if you want to change the password for the file
    Preview
  • Encrypting existing files using vault
    Preview
  • Decryption of the encrypted file
    Preview

Preview

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Wordpress Development Company

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