-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathFilter_Playbook.yml
50 lines (40 loc) · 1.28 KB
/
Filter_Playbook.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
40
41
42
43
44
45
46
47
48
49
50
---
- name: Check Ansible Filter
hosts: localhost
gather_facts: false
vars:
- my_var: test
tasks:
- name: Show default value
debug:
msg: "{{ my_var | default('default-variables') }}"
- name: Join list into a string
debug:
msg: "{{ ['apple', 'banana', 'cherry'] | join('_^_') }}"
- name: Split string into a list
debug:
msg: "{{ 'apple^banana^cherry' | split('^') }}"
- name: Get length of list
debug:
msg: "{{ ['apple', 'banana', 'cherry'] | length }}"
- name: Sort list
debug:
msg: "{{ ['hi', 'banana', 'apple', 'cherry'] | sort }}"
- name: Remove duplicates from list
debug:
msg: "{{ ['apple', 'banana', 'apple', 'apple', 'banana', 'cherry'] | unique }}"
- name: Replace substring in string
debug:
msg: "{{ 'hello world' | replace('world', 'Ansible') }}"
- name: Convert string to uppercase
debug:
msg: "{{ 'hello world' | upper }}"
- name: Convert string to lowercase
debug:
msg: "{{ 'HELLO WORLD' | lower }}"
- name: Convert data to YAML
debug:
msg: "{{ {'name': 'John', 'age': 30} | to_yaml }}"
- name: Convert data to JSON
debug:
msg: "{{ {'name': 'John', 'age': 30} | to_json }}"