diff options
| author | boom2 <blizzack@blizzack.com> | 2023-11-22 22:39:56 -0500 |
|---|---|---|
| committer | boom2 <blizzack@blizzack.com> | 2023-11-22 22:39:56 -0500 |
| commit | d00dff82886992cdad94ac70bc438ec5b2bda1a2 (patch) | |
| tree | fc6e286816e8aaf48043b92fd81fc109569989f5 /ansible_stuff.org | |
| parent | 74b826b2e9783df019eea265772746cab691ce54 (diff) | |
more playbooks related to bash configs
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 |
