Ansible Notes
Notes I took while working with Ansible for the first time.
- terms (source):
orchestration tools: designed to provision the servers themselves, e.g. CloudFormation, Terraformconfiguration management tools: designed to install and manage software on existing servers, e.g. Chef, Puppet, Ansible, and SaltStack
- Ansible is a procedural configuration management tool
-
list hosts that will be targeted by the given playbook
$ ansible-playbook pb.yml -i ../environments/dev --list-hosts -
verbose mode up to 3 levels
$ ansible-playbook pb.yml -i ../environments -vvv role_pathis relative the location of theansible.cfgansible config file-
$ ansible-playbook pb.yml --check -
├── environments │ ├── cross_env_vars │ ├── dev │ │ ├── ec2.ini -> ../ec2.ini │ │ ├── ec2.py -> ../ec2.py │ │ └── group_vars │ │ ├── all │ │ │ └── cross_env_vars -> ../../../cross_env_vars │ │ └── tag_role_api │ │ └── vars │ │ └── vault │ ├── prod │ │ ├── ec2.ini -> ../ec2.ini │ │ ├── ec2.py -> ../ec2.py │ │ └── group_vars │ │ ├── all │ │ │ └── cross_env_vars -> ../../../cross_env_vars │ │ └── tag_role_api │ │ └── vars │ │ └── vault │ ├── ec2.ini │ └── ec2.py with_itemsusing dicts-
templateaccepts vars (this is not documented clearly)- template: src=test.j2 dest=/tmp/File1 vars: myTemplateVariable: myDirName - template: src=test.j2 dest=/tmp/File2 vars: myTemplateVariable: myOtherDir