ansible all -i inventory -e ansible_user=centos -e ansible_password=xyz123 -m shell -a "df -h"
-i inventory file -e extra or environment variables ansible_user : speciat variable name for the user-account to use ansible_password : speciat variable name for the user-account-password to use -m : name of the module
Ansible Scripts are referred as Playbooks and playbooks are written using YAML.
YAML : Yet Another Markup Language :
Markup Language : It's a presentation language.
YAML is very simple. Things to be remembered while learning YAML
1) YAML is intendation specific
2) YAML is all about Dictionary , List & a Map
3) YAML Files should always be ending with either .yml or .yaml
- Apple
- Orange
- Strawberry
- Mango
martin:
name: Martin D'vloper
job: Developer
skill: Elite
- martin:
name: Martin D'vloper
job: Developer
skills:
- python
- perl
- pascal
- tabitha:
name: Tabitha Bitumen
job: Developer
skills:
- lisp
- fortran
- erlang
PS : A Key with multiple values is referred as a list
A playbook is a list of plays.
A Play is a list of tasks
A Task is a list of actions that you want to execute.
ansible-playbook -i inv-dev -e ansible_user=centos -e ansible_password=DevOps321 -e COMPONENT=mongodb robot.yml
Files : just copy the file as is Templates : Copy the file along with the mentioned variables in the file as a part of the copy
roles-example/ ├── defaults │ └── main.yml ├── files ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── README.md ├── tasks │ └── main.yml ├── templates ├── tests │ ├── inventory │ └── test.yml └── vars └── main.yml
---> Frontend UI Fails Intermittently ( which ensure you see no items or display of catalogue )
Whenever the infra is dynamic or not in a position to maintan the static inventory or whenever you want come some config-management to happen as a part of the boot-strapping, prefer using ansible-pull. Ansible-pull expects ansible to be installed on the machine you're running.
So, the easiest option is to install ANSIBLE on the lab ami and keep it ready and prefer this AMI with Ansible as a base image
Ex: ansible-pull-U https_git_repo_url playboon-name.yml
ansible-pull -U https://github.com/jaindeepak2008/ansible-b52.git -e COMPONENT=mongodb -e APP_VERSION=0.0.8 -e ENV=dev robot-pull.yml