From 89e849d012cf9706d784a56f90ebb0430baf2438 Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Mon, 29 Aug 2022 10:27:19 +0200 Subject: [PATCH] new slides --- ansible_101/README.md | 16 +++ ansible_101/ansible.cfg | 17 +++ ansible_101/how-i-ansible-main.zip | Bin 0 -> 7736 bytes ansible_101/index.md | 162 +++++++++++++++++++++++++++++ ansible_101/play_w_roles.yml | 8 ++ ansible_101/requirements.txt | 6 ++ ansible_101/requirements.yml | 12 +++ ansible_101/simple_play.yml | 16 +++ 8 files changed, 237 insertions(+) create mode 100644 ansible_101/README.md create mode 100644 ansible_101/ansible.cfg create mode 100644 ansible_101/how-i-ansible-main.zip create mode 100644 ansible_101/index.md create mode 100644 ansible_101/play_w_roles.yml create mode 100644 ansible_101/requirements.txt create mode 100644 ansible_101/requirements.yml create mode 100644 ansible_101/simple_play.yml diff --git a/ansible_101/README.md b/ansible_101/README.md new file mode 100644 index 0000000..c5ad56f --- /dev/null +++ b/ansible_101/README.md @@ -0,0 +1,16 @@ +How I ansible +============= + +How to run the slides: + +```sh +pipx install present +present slides.md +``` + +_[pipx](https://pypa.github.io/pipx/) installs python tools in a dedicated environment to prevent overlapping dependencies_ + +--- + +Made with ❤️ and 🐍. + diff --git a/ansible_101/ansible.cfg b/ansible_101/ansible.cfg new file mode 100644 index 0000000..bec3b8d --- /dev/null +++ b/ansible_101/ansible.cfg @@ -0,0 +1,17 @@ +[defaults] +nocows = 1 +# private_key_file = files/id_ed25519 +# remote_user = ansible +inventory = ./inventory +roles_path = ./roles +collections_paths = ./collections +stdout_callback = yaml # readable output + +[privilege_escalation] +become_allow_same_user = True +become = True # also be root, su if needed + +[ssh_connection] +ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s +control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r +control_path_dir = tmp/ diff --git a/ansible_101/how-i-ansible-main.zip b/ansible_101/how-i-ansible-main.zip new file mode 100644 index 0000000000000000000000000000000000000000..a8f918c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_8%5mDZkn zMO0_njM-A>7dS^T7zN!;YZW`(+Wvh%OK_8LiKBBgYjKbF@o#&plkWF^e##quO0G~p zjYVhMlf4D;*=MTPD&JY_{)+3_^i1oB!ZG1rrd&Gxz~fvW-;?9%F>`~$ zW?uPppr+UFj#`fc`}QE0woBj7sCQdxual8q9nic}&!xtLK}34&EqsE5BK8^Mm90Q{&F;S~k)0tA58@>3i)vUB#c> zP@3J)mnnC~?fvuLU4IJh+1~$f?!o2*7S&5nWY2q~bX)d&{`{9k`&pB@`5&ru>$83G z&|Y}tsp7<5eg3qrT~{xaN=iFw{|Ro~_?9L44#%S2jYlPY;`TBfJ$%Ki+;8386KuAR zo_48!f8g?DPsGgs%kD^eC)&!+z0-Pqy?W=33w!tr>KgAJmrk?((-E<$_vXDjjr?IQ zi~OG@=j;9A$Tx6Od({8Mx#x&s-(2qGA) z7#OgbggKCha2&))^f54yX%Hh_7_l0OZA1*+Q1r1MgrN(Wuo?=gv#^c?p_`08go7~I zgc+;JD5ERL13Ks?qmR@eOkPfe$;jh22$LaADUeAp3>qDQutD+P%Yxm_paC)Dh8Zjs zV44RSEkT%f7N2=YgA?$6FFvP&Mo$n%OR(Z`Dw5IgaStqZKvEp~XbQ*P|6mJpqH zKpk;VutCz-e6lRUn|~mNLr74^9Kr$>H-E^s43vjZyXmk54hc#0jylLrNCHpbAtxk3 z9)#Kn?V+P|+lkM=JiNqNUxwBbhj|Z@?9uz;2=B#^Vm_W!53vWme~qx`19p3G^|lcK z1Th%BUyCsKA|KWO!tCV+c(byBv`I5aGX!!mFsu}2V9;Q&G)*!|Nlr;JNHVuDG)YWO cOinU0ut-fcNi{SzwJ./ +├── defaults +│ └── main.yml +├── files +│ └── etc +│ └── foo +│ └── config.ini +├── meta +│ ├── argument_specs.yml +│ └── main.yml +├── tasks +│ └── main.yml +├── templates +│ └── etc +│ └── foo +│ └── conf.d +│ └── special.ini.j2 +└── vars + └── main.yml +``` +--- +# Roles + +- `meta` +- `defaults` vs `vars` +- `files` vs `templates` +- Advanced tasks + +--- + +# Advances topics + +- 🔐 Secrets +- Create your own roles +- Create your own collections + - If you need your own plugins or modules + +--- + +# Secrets + +`$ ansible-galaxy collection install community.general` + +```yaml +password: "{{ lookup('community.general.passwordstore', 'accounts/foobar.com') }}" +aws_secret_key: "{{ lookup('community.general.passwordstore', 'accounts/aws subkey=secret_key') }}" +aws_access_key: "{{ lookup('community.general.passwordstore', 'accounts/aws subkey=access_key') }}" +``` + +See: https://docs.ansible.com/ansible/latest/collections/community/general/passwordstore_lookup.html + +--- + +# ❓ questions ❓ + diff --git a/ansible_101/play_w_roles.yml b/ansible_101/play_w_roles.yml new file mode 100644 index 0000000..35d442e --- /dev/null +++ b/ansible_101/play_w_roles.yml @@ -0,0 +1,8 @@ +--- + +- hosts: all + roles: + - common + - role: that_other_role + some_var: 2342 + diff --git a/ansible_101/requirements.txt b/ansible_101/requirements.txt new file mode 100644 index 0000000..243e4c4 --- /dev/null +++ b/ansible_101/requirements.txt @@ -0,0 +1,6 @@ +# ansible +ansible~=6.0 + +# roles + +# collections diff --git a/ansible_101/requirements.yml b/ansible_101/requirements.yml new file mode 100644 index 0000000..cb36e75 --- /dev/null +++ b/ansible_101/requirements.yml @@ -0,0 +1,12 @@ +--- + +collections: + - name: community.general + version: '>=2.5.1' # parted, copr module + - name: ansible.posix + version: '>=1.2.0' # mount, firewalld module + - name: community.libvirt + version: '>=1.0.1' # virt_pool, virt_net module + +roles: [] + diff --git a/ansible_101/simple_play.yml b/ansible_101/simple_play.yml new file mode 100644 index 0000000..e857dd5 --- /dev/null +++ b/ansible_101/simple_play.yml @@ -0,0 +1,16 @@ +--- +- hosts: all, !supermicro + tasks: + - name: Install foo + tags: install + ansible.builtin.apt: + name: foo + + - name: Setup foo + tags: configure + ansible.builtin.copy: + src: etc/foo/config.ini + dest: /etc/foo/config.ini + notify: + - reload foo +