81837
This commit is contained in:
parent
a3ce91dc9d
commit
8eaabf9544
@ -15,6 +15,7 @@ inventory = inventory.ini
|
|||||||
remote_user = user-ansible
|
remote_user = user-ansible
|
||||||
host_key_checking = false
|
host_key_checking = false
|
||||||
vault_password_file = /root/ansible/vault.key
|
vault_password_file = /root/ansible/vault.key
|
||||||
|
#callbacks_enabled = timer, profile_roles, profile_tasks
|
||||||
|
|
||||||
[privilege_escalation]
|
[privilege_escalation]
|
||||||
become = True
|
become = True
|
||||||
|
8
assert_filter.yaml
Normal file
8
assert_filter.yaml
Normal file
@ -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 ] )"
|
29
filemap.yaml
Normal file
29
filemap.yaml
Normal file
@ -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
|
11
plugin-lines.yml
Normal file
11
plugin-lines.yml
Normal file
@ -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') }}"
|
Loading…
x
Reference in New Issue
Block a user