diff options
Diffstat (limited to 'ansible_stuff.org')
| -rw-r--r-- | ansible_stuff.org | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/ansible_stuff.org b/ansible_stuff.org index 6dc98eb..99f00db 100644 --- a/ansible_stuff.org +++ b/ansible_stuff.org @@ -530,6 +530,16 @@ dpierre@boom2:~$ ansible all -a "uptime" 14:00:39 up 5 min, 1 user, load average: 0.15, 0.05, 0.01 +- copying files that are owned by myself +ansible all -m copy -a "src=./file.txt dest=~/myfile.txt" + +- change file permissions +ansible all -m file -a "dest=/var/www/file.txt mode=600 owner=sammy group=sammy" --become -K + +- invoking services +ansible all -a "/sbin/reboot" --become -K + + interesting... we can use a different ssh key with our ansible commands if we wish like so: @@ -552,3 +562,44 @@ ansible all -m setup ansible all -m setup -a "gather_subset=min" ansible all -m setup -a " filter=*ipv* " ansible all -m setup > ../bbox-system.json + + +- to list out the tasks of a playbook: + +ansible-playbook 12-playbook-copy-directory.yml --list-tasks + +playbook: 12-playbook-copy-directory.yml + + play #1 (all): 12 - Playing with Ansible - copy directories from control to managed node TAGS: [] + tasks: + copy entire directory TAGS: [step1] + copy directory contents TAGS: [step2] + +- to list out the tags of a playbook: + + ansible-playbook 12-playbook-copy-directory.yml --list-tags + + playbook: 12-playbook-copy-directory.yml + + play #1 (all): 12 - Playing with Ansible - copy directories from control to managed node TAGS: [] + TASK TAGS: [step1, step2] + +- execute tasks by tag + + ansible-playbook 12-playbook-copy-directory.yml --tags=step2 + + - skipping tasks by tag + + ansible-playbook 12-playbook-copy-directory.yml --exclude-tags=step1 + + - starting execution at specific task + + ansible-playbook 12-playbook-copy-directory.yml --start-at-task=step4 + +- limiting targets for execution to a set of workstations + - many typically playbooks set up their target as 'all' by default, + and sometimes you want to limit the group or single server that + should be the target for that setup. You can use -l (limit) to set + up the target group or server in that play. + + ansible-playbook -l dev-stations 12-playbook-copy-directory.yml |
