summaryrefslogtreecommitdiff
path: root/ansible_stuff.org
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_stuff.org')
-rw-r--r--ansible_stuff.org68
1 files changed, 67 insertions, 1 deletions
diff --git a/ansible_stuff.org b/ansible_stuff.org
index a2b8556..6dc98eb 100644
--- a/ansible_stuff.org
+++ b/ansible_stuff.org
@@ -384,7 +384,7 @@ Connection to 192.168.0.220 closed.
-to-
- ;inventory=~/.ansible/hosts
+ inventory=~/.ansible/hosts
https://www.educba.com/ansible-hosts-file/
@@ -410,6 +410,22 @@ ansible all -m ping
ansible dev -m ping
+- the above reference using the inventory file '~/.ansible/hosts' but
+ when executing ansible commands we can use any inventory file as
+ long as we use the '-i' switch to explicitly point to it. like so:
+
+ ansible all -i /some/path/to/my/inventory_file -m ping
+
+ ansible-playbook -i /some/path/to/my/inventory_file 01-playbook-hello.yml
+
+ - the following resource shows so many different ways to setup your
+ inventory file(s). it shows detailed ways of organizing nodes
+ into groups and subgroups, inventory variables, use patterns to
+ target different groups of servers when running commands &
+ playbooks.
+ https://assets.digitalocean.com/books/how-to-manage-remote-servers-with-ansible.pdf
+
+
- create a file on a host using ansible
https://phoenixnap.com/kb/ansible-create-file
@@ -486,3 +502,53 @@ did a lil research on more resources
https://www.lifewire.com/download-free-books-3482754
https://assets.digitalocean.com/books/how-to-manage-remote-servers-with-ansible.pdf
+
+https://www.digitalocean.com/community/cheatsheets/how-to-use-ansible-cheat-sheet-guide
+
+
+To execute a command on a node, use the -a option followed by the
+command you want to run, in quotes.
+
+some more examples of an adhoc commands that can be run:
+
+
+dpierre@boom2:~$ ansible all -a "df -Th"
+
+192.168.0.220 | CHANGED | rc=0 >>
+Filesystem Type Size Used Avail Use% Mounted on
+/dev/root ext4 98G 17G 77G 18% /
+devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
+tmpfs tmpfs 32M 1.2M 31M 4% /run
+tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
+cgroup_root tmpfs 8.0M 0 8.0M 0% /sys/fs/cgroup
+/dev/sda1 ext4 89M 82M 73K 100% /boot
+
+
+dpierre@boom2:~$ ansible all -a "uptime"
+
+192.168.0.220 | CHANGED | rc=0 >>
+ 14:00:39 up 5 min, 1 user, load average: 0.15, 0.05, 0.01
+
+
+interesting... we can use a different ssh key with our ansible
+commands if we wish like so:
+
+ ansible all -a "df -Th" --private-key=~/.ssh/some/custom_ssh_key
+
+this is also mentioned in the comments within '~/.ansible.cfg' that we
+manufactured on <2023-10-23 Mon>
+
+grrr...so many options!! we can add a private key directly to the
+inventory file we choose to use as well. there is a variable called
+'ansible_ssh_private_key_file=~/.ssh/some/custom_ssh_key'
+
+this resource below mentions this some more:
+https://www.digitalocean.com/community/cheatsheets/how-to-manage-multiple-servers-with-ansible-ad-hoc-commands
+
+we use the '-m' switch on ansible commands to reference a command via
+the 'command module' to execute that command on the remote server(s).
+
+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