-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadvanced_example.yml
39 lines (31 loc) · 1008 Bytes
/
advanced_example.yml
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
---
# Advanced Example Playbook for "sh" Ansible Module
- name: Test Play
hosts: ubuntu, centos, controller
become: true
tasks:
###################################### Example 1
- name: Testing RegExp search with operators # if condition-cmd-stdout = RegExp-match-of /eth[0-9]/ AND condition-cmd-rc > 0
sh:
cmd: 'echo "Execute some commands"'
condition: 'ifconfig -a'
lang: bash
regexp: True
if_stdout: 'eth[0-9]'
if_stdout_operator: '=' # "=" must be in quotes
if_rc: 0
if_rc_operator: '>'
register: debug
- debug:
var: debug
###################################### Example 2
- name: Testing rc operators # Execute the command if condition-command-rc < 1
sh:
cmd: 'echo "Execute some commands"'
condition: 'ifconfig -a'
lang: bash
if_rc: 1
if_rc_operator: '<'
register: debug
- debug:
var: debug