summaryrefslogtreecommitdiff
path: root/ansible-practice/system/15-playbook-fetch-file.yml
diff options
context:
space:
mode:
authorboom2 <blizzack@blizzack.com>2023-12-21 15:49:16 -0500
committerboom2 <blizzack@blizzack.com>2023-12-21 15:49:16 -0500
commit200680e7c8cbd6b4426c3ce232568b1e06446bde (patch)
treeb122f103cc4dce8cea078c20dac107612399640e /ansible-practice/system/15-playbook-fetch-file.yml
parenta21b2f4bb64bd0f633d8a6a15f27a73103df70c0 (diff)
- renamed playbook to follow convention
-- add /etc/rc.d/rc.M in 'fetch file playbook' for future clamav playbook
Diffstat (limited to 'ansible-practice/system/15-playbook-fetch-file.yml')
-rw-r--r--ansible-practice/system/15-playbook-fetch-file.yml49
1 files changed, 49 insertions, 0 deletions
diff --git a/ansible-practice/system/15-playbook-fetch-file.yml b/ansible-practice/system/15-playbook-fetch-file.yml
new file mode 100644
index 0000000..6d93219
--- /dev/null
+++ b/ansible-practice/system/15-playbook-fetch-file.yml
@@ -0,0 +1,49 @@
+# fetch/download a file(s) from managed nodes to the controller node
+#
+# - use cases:
+# - pulling log files
+# - grabbing public keys
+#
+#
+---
+- name: "15 - custom ansible - fetch file"
+ hosts: dev
+ become: yes # Run tasks with root/sudo privileges
+ vars:
+ sys_file_list:
+ - /etc/rc.d/rc.firewall
+ - /etc/rc.d/rc.M
+ - /etc/ssh/sshd_config
+
+#
+# - playing w/ loops as well
+#
+ tasks:
+ - name: pull sshd & firewall configs
+ ansible.builtin.fetch:
+ src: "{{ item }}"
+ dest: ~/repos/ansible_repo/ansible-practice/system/
+ loop: "{{ sys_file_list }}"
+ tags: ['fetch_sys_configs']
+
+#
+# - essentially, the same code as above except done one task at a time
+#
+# - name: pull sshd config
+# ansible.builtin.fetch:
+# src: /etc/ssh/sshd_config
+# dest: ~/repos/ansible_repo/ansible-practice/system/
+# tags: ['fetch_sshd_config']
+#
+# - name: pull firewall config
+# ansible.builtin.fetch:
+# src: /etc/rc.d/rc.firewall
+# dest: ~/repos/ansible_repo/ansible-practice/system/
+# tags: ['fetch_firewall_config']
+#
+
+# References
+#
+# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/fetch_module.html
+# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_loops.html
+# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#list-variables