Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux_wiki:ansible [2018/06/30 22:44] billdozor [Playbook Directory Structure] |
linux_wiki:ansible [2018/08/07 15:45] billdozor [Playbook Directory Structure] |
||
---|---|---|---|
Line 41: | Line 41: | ||
* Each system administrator would then clone a copy of the repo into their home directory for local changes/ | * Each system administrator would then clone a copy of the repo into their home directory for local changes/ | ||
* Have an automated job sync the shared location every so often. | * Have an automated job sync the shared location every so often. | ||
- | * Example: Have cron perform a git pull for / | + | * Example: Have cron perform a git pull for /ansible/ every 30 mins. |
\\ | \\ | ||
Line 68: | Line 68: | ||
* Cron Job to execute inventory generation script: / | * Cron Job to execute inventory generation script: / | ||
- | * Example: Executes | + | * Example: Executes every 30 minutes. (*/30 * * * *) |
* Script that generates inventory files: / | * Script that generates inventory files: / | ||
Line 237: | Line 237: | ||
\\ | \\ | ||
**Playbooks map ansible groups to roles** | **Playbooks map ansible groups to roles** | ||
- | * Example playbook< | + | * Example playbook< |
# Description: | # Description: | ||
# Last Updated: 2018-04-08 | # Last Updated: 2018-04-08 | ||
Line 261: | Line 261: | ||
If you do need to gather facts, consider gathering a subset of facts instead of everything in order to keep the fact collection fast. | If you do need to gather facts, consider gathering a subset of facts instead of everything in order to keep the fact collection fast. | ||
- | * Example: Collect only the ansible_distribution facts< | + | * Example: Collect only the ansible_distribution facts< |
gather_facts: | gather_facts: | ||
# Gather only ansible_distribution info (OS attributes) | # Gather only ansible_distribution info (OS attributes) | ||
Line 278: | Line 278: | ||
* You can test your subset commands like this | * You can test your subset commands like this | ||
* ad-hoc< | * ad-hoc< | ||
+ | |||
+ | **Available Fact Subsets**: | ||
+ | * all | ||
+ | * min | ||
+ | * hardware | ||
+ | * network | ||
+ | * virtual | ||
+ | * ohai | ||
+ | * facter | ||
\\ | \\ | ||
Line 341: | Line 350: | ||
- Navigate to the playbooks directory< | - Navigate to the playbooks directory< | ||
- Copy your playbook template to a new playbook yaml file.< | - Copy your playbook template to a new playbook yaml file.< | ||
- | - Playbook Template< | + | - Playbook Template< |
# Description: | # Description: | ||
# Last Updated: 2018-03-15 | # Last Updated: 2018-03-15 | ||
Line 349: | Line 358: | ||
- hosts: | - hosts: | ||
- group_name_here | - group_name_here | ||
+ | |||
# roles: located in ../roles/ | # roles: located in ../roles/ | ||
roles: | roles: | ||
# role: role to assign to hosts, tags: tag(s) to give entire role | # role: role to assign to hosts, tags: tag(s) to give entire role | ||
- { role: role-name, tags: tag-name } | - { role: role-name, tags: tag-name } | ||
+ | |||
# Do not gather host facts for this playbook (comment out/remove if you need facts) | # Do not gather host facts for this playbook (comment out/remove if you need facts) | ||
gather_facts: | gather_facts: | ||
</ | </ | ||
- | - Edit the new playbook<code bash>vim ansible/ | + | - Edit the new playbook |
- hosts: my_ansible_group | - hosts: my_ansible_group | ||
roles: | roles: |