blob: 539db80b7943b872ea4aa3a9f4cbfa27c69e75de (
plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
- hosts: localhost
tasks:
- debug:
msg: Ansible version={{ ansible_version.major }}.{{ ansible_version.minor }}
- hosts: all
tasks:
# Create unwritable /tmp/console-None.log
# This ensures that no further task can write to it without failing.
# A task trying to write to /tmp/console-None.log is considered broken
# because zuul_log_id is missing.
- name: Create unwritable /tmp/console-None.log
file:
path: /tmp/console-None.log
state: touch
mode: 0444
run_once: True
- name: Start zuul_console daemon
zuul_console:
port: "{{ test_console_port }}"
- name: Create first file
copy:
content: "command test one\n"
dest: "{{ ansible_user_dir }}/command_test_file1"
- name: Create second file
copy:
content: "command test two\n"
dest: "{{ ansible_user_dir }}/command_test_file2"
- name: Show contents of first file
command: "cat {{ ansible_user_dir }}/command_test_file1"
- name: Show contents of second file
# We use a sleep here to ensure that we log even after
# a period of no logging.
shell: "sleep 6 && cat {{ ansible_user_dir }}/command_test_file2"
# Test a task with a handler
- name: Run a command with notifying a handler
command: /bin/true
notify: test handler
# Test cleanup task
- name: Block with cleanup
block:
- name: Run a command
command: /bin/false
rescue:
- name: Rescue task
command: echo "This is a rescue task"
always:
- name: Always task
command: echo "This is an always task"
handlers:
- name: test handler
command: echo "This is a handler"
- hosts: all
strategy: free
tasks:
- name: Command task 1 within free strategy
command: echo "First free task"
- name: Command task 2 within free strategy
command: echo "Second free task"
# Test a role that has an include_role
- hosts: all
strategy: linear
roles:
- include-a-role
- hosts: compute1
tasks:
- name: Single command
command: "echo single"
# Test commands within loops
- name: Command with loop
shell: |
echo {{ item }}
with_items:
- item_in_loop1
- item_in_loop2
- name: Failing command with loop
shell: |
echo {{ item }}
exit 1
with_items:
- failed_in_loop1
- failed_in_loop2
ignore_errors: True
# Try transitive includes two different ways
- hosts: compute1
tasks:
- include_role:
name: include-echo-role
vars:
item: transitive-one
- include_role:
name: include-echo-role
vars:
item: transitive-two
- hosts: compute1
roles:
- role: include-echo-role
item: transitive-three
- role: include-echo-role
item: transitive-four
- hosts: compute1
tasks:
- name: Command Not Found
command: command-not-found
failed_when: false
- hosts: compute1
tasks:
- name: Debug raw variable in msg
debug:
msg: '{{ ansible_version }}'
- name: Debug raw variable in a loop
debug:
msg: '{{ ansible_version }}'
loop:
- 1
- 2
|