DevOps Classroom notes 31/Jul/2025

Ansible playbook

Ansible autocomplete

  • Steps
sudo apt install python3-argcomplete -y
  • Now appending the following to the file ~/.bashrc
eval "$(register-python-argcomplete ansible)"
eval "$(register-python-argcomplete ansible-config)"
eval "$(register-python-argcomplete ansible-playbook)"
eval "$(register-python-argcomplete ansible-galaxy)"
  • now in the current terminal source ~/.bashrc
  • when you are executing ansible commands we can use tab to view options

Execution

  • Verify playbook syntax
ansible-playbook --syntax-check -i hosts <playbook>.yaml
  • Ansible also has dry run (which doesnot work in certain cases)
ansible-playbook --check --inventory hosts apache.yaml
  • To execute ansible playbook
ansible-playbook -i hosts <playbook>.yaml

Reading ansible playbook execution.

  • Ansible adds an extra task to collect facts
  • Any task will result with
    • ok: Desired state is met
    • changed: Task was executed
    • failed: Task failed

Lets continue playbook for apache2

  • Manual steps
sudo systemctl start apache2
sudo systemctl enable apache2
sudo apt install php libapache2-mod-php -y
  • copy the test.php file
  • Refer Here for the changes done.

Exercise:

  • Install nginx , php and use the same test page.
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

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
Exit mobile version
%%footer%%