Skip to content

vimalmenon/learn-ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learn Ansible

Prerequisite

  • Software Installed
    • VirtualBox installed
    • Vagrant

Modules

  • Copy
  • Ping
  • Command
  • Package
    • yum, apt
  • lineinfile
  • Fetch
  • Url
  • zip
  • user
  • Git
  • Roles
  • Collection
  • post_tasks
  • pre_tasks
  • handlers
  • Assert
  • Module
  • Rescue
  • Register
  • Ignore Errors

Create VirtualEnv

python -m venv ./venv

Activate VirtualEnv

source ./venv/bin/activate

Install ansible

pip install ansible

Vagrant get Id

vagrant global-status --prune

Vagrant create VM's

vagrant up
sh ./up.sh

Vagrant destroy

vagrant destroy {id}
sh ./destory.sh  

Vagrant list the VM Downloaded

vagrant box list

Ansible Adhoc command

ansible app -i ./inventory -a "whoami"

Ansible Adhoc command with module ping

ansible app -i ./inventory -m ping

Ansible Adhoc command with module setup

ansible app -i ./inventory -m setup

SSH without checking known_hosts

ssh -o StrictHostKeyChecking=no vagrant@192.168.33.10 -i ${key}

Running Simple Playbook file in example Playbook1

ansible-playbook ./examples/Playbook1/simple.play.yml -i inventory -v

Checking syntax for simple Playbook file in example Playbook1

ansible-playbook ./examples/Playbook1/simple.play.yml -i inventory --syntax-check

Encrypt var files

ansible-vault encrypt <file-path>

Ansbile galaxy collection

ansible-galaxy collection init local.colors

Playbook sample

ansible-playbook ./examples/Playbook2/01.play.yml -i inventory --syntax-check
ansible-playbook ./examples/Playbook3/01.play.yml -i inventory --syntax-check

Reference

VM Images

https://www.youtube.com/watch?v=fwrpM7Svfwk https://www.youtube.com/watch?v=DAnMyBZ8-Qs https://www.youtube.com/watch?v=tcP_gxOo7mk

Releases

No releases published

Packages

No packages published

Languages