-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathansible-notes.txt
More file actions
43 lines (34 loc) · 1.2 KB
/
ansible-notes.txt
File metadata and controls
43 lines (34 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
- set_fact:
vra_insync_node: "{{ cluster_status.stdout | from_json | json_query(\"[?syncStatus=='Sync'].nodeHost\") }}"
ansible pitfall:
the problem here is the serial: 1
- name: restart vra cluster
hosts: vra
tags: vra-cluster-restart
serial: 1
max_fail_percentage: 0
tasks:
- name: test
shell: touch /tmp/bla`date +%F%T`
run_once: true
delegate_to: bla.example.com
run_once does not work in conjunction with when, if execution is skipped on the first host because of the when condition it is not executed at all
#run debug stuff localy
ansible -m debug -a msg="{{ '-'.join(('str1', 'str2', 'str3')) }}" localhost
#print all vars of a server
ansible-inventory inventories/myinv --host mygroup[0] |less
old:
ANSIBLE_CALLBACK_WHITELIST=profile_tasks ansible-playbook ...
new:
ANSIBLE_CALLBACK_WHITELIST=ansible.posix.profile_tasks ansible-playbook ...
regex Example:
- name: Set fact stage
set_fact:
company_environment: "{{ ansible_vars_file.stdout | regex_findall('environment:(.*)') | first | default ('') }}"
Debug wait:
- name: Wait
pause:
prompt: Press enter
Good jinja ressources:
https://ttl255.com/jinja2-tutorial-part-3-whitespace-control/
http://jinja.quantprogramming.com/