diff --git a/ansible.cfg b/ansible.cfg index b17205e..6e860b4 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -15,6 +15,7 @@ inventory = inventory.ini remote_user = user-ansible host_key_checking = false vault_password_file = /root/ansible/vault.key +#callbacks_enabled = timer, profile_roles, profile_tasks [privilege_escalation] become = True diff --git a/assert_filter.yaml b/assert_filter.yaml new file mode 100644 index 0000000..87b39a9 --- /dev/null +++ b/assert_filter.yaml @@ -0,0 +1,8 @@ +--- +- name: demonstrate filters + hosts: localhost + tasks: + - name: manipulate a list and check + assert: + that: + - "{{ [ 2, 3, 1, 2, 4, 2 ] | sort | unique | list }} is eq( [ 1, 2, 3, 4 ] )" diff --git a/filemap.yaml b/filemap.yaml new file mode 100644 index 0000000..f04b4da --- /dev/null +++ b/filemap.yaml @@ -0,0 +1,29 @@ +--- +- name: showing map + hosts: all + gather_facts: no + become: yes + vars: + - basedir: /var/www/html + tasks: + - name: showing basedir + debug: + var: basedir + - name: showing files in basedir + find: + paths: "{{ basedir }}" + recurse: yes + register: basedir_files + - name: showing current variable contents to understand why we need map + debug: + var: basedir_files + - name: show files based on map attribute path without list - will show error + set_fact: + webfiles: "{{ basedir_files['files'] | map(attribute='path') }}" + - debug: + var: webfiles + - name: show files based on map attribute with list + set_fact: + webfileslist: "{{ basedir_files['files'] | map(attribute='path') | list }}" + - debug: + var: webfileslist diff --git a/plugin-lines.yml b/plugin-lines.yml new file mode 100644 index 0000000..228914b --- /dev/null +++ b/plugin-lines.yml @@ -0,0 +1,11 @@ +--- +- name: checking out lines and pipes lookup plugins + hosts: localhost + gather_facts: no + tasks: + - name: print the first line of any file + debug: + msg: "{{ item[0] }}" + loop: + - "{{ query('lines', 'cat /etc/hosts') }}" + - "{{ query('lines', 'cat /etc/passwd') }}"