- You are working on your playbook at
~/dev/mycoolplaybook
- You decide to extract a role to post it on the galaxy
- Copy
coolrole
frommycoolplaybook
- Copy to
~/somewhere/github/mycoolrole
- Git init the directory and add in the galaxy metadata.
- Push it to github.
- Add it to the galaxy.
- Galaxy install the role.
- Rename the role declaration in your
site.yml
to match the new name.
- Copy
- Run the role to make sure it works after all of that shuffling around.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# This is a single playbook. | |
- name: all servers | |
hosts: all | |
sudo: true | |
roles: | |
- { role: foo, tags: [common, foo] } | |
- { role: bar, tags: [common ,bar] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[a, b, c]|difference([b]) will return [a, c] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- stat: path=somewhere/awesome | |
register: foo_stats | |
- include: world.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# host_vars/all.yml | |
foo_master = "{{ groups['blah'][0] }}" | |
# ^ For some reason foo_master is ignored here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mybook/roles/common/files/foo | |
foobar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hosts_file = File.readlines('/path/to/hosts') | |
group_names = [] | |
host_names = [] | |
hosts_file.each do |line| | |
line.chomp! | |
first_char = line[0] | |
last_char = line[-1, 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[defaults] | |
transport = ssh | |
[ssh_connection] | |
ssh_args = -o ForwardAgent=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deploy@ansible-test:/usr/local/rvm$ id | |
uid=1000(deploy) gid=1000(deploy) groups=1000(deploy),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),111(lpadmin),112(sambashare) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- debug: var=version_init.stdout != v{{app_node_version}} | |
TASK: [app | debug var=version_init.stdout != v{{app_node_version}}] ********** | |
ok: [192.168.1.12] => { | |
"item": "", | |
"version_init.stdout": "v0.10.27" | |
} |