mirror of
https://github.com/kneutron/ansitest.git
synced 2025-01-16 04:42:55 +08:00
Add files via upload
This commit is contained in:
parent
6db8e9f9e4
commit
36ca496c33
3
ans-run-demo-lowercase-sr.sh
Normal file
3
ans-run-demo-lowercase-sr.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
ansible-playbook -i localhost demo-ansible-lowercase-search-replace.yml
|
||||||
|
|
24
demo-ansible-lowercase-search-replace.yml
Normal file
24
demo-ansible-lowercase-search-replace.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- name: Demo lowercase and search/replace in var
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
answers: "no so YES no"
|
||||||
|
|
||||||
|
# mastering ansible 4th ed. 2021, p.202
|
||||||
|
# REF: https://stackoverflow.com/questions/55927273/how-ansible-assign-values-to-variables
|
||||||
|
# REF: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html
|
||||||
|
|
||||||
|
# replace all no with yes and lowercase it all
|
||||||
|
tasks:
|
||||||
|
- name: do the thing
|
||||||
|
debug:
|
||||||
|
msg:
|
||||||
|
- "Original: {{ answers }}"
|
||||||
|
- "Expected result: {{ answers | replace('no', 'yes') | lower }}"
|
||||||
|
|
||||||
|
- set_fact: my_result="{{ answers | replace('no', 'yes') | lower }}"
|
||||||
|
|
||||||
|
- name: show result
|
||||||
|
debug:
|
||||||
|
msg: "{{ my_result }}"
|
Loading…
x
Reference in New Issue
Block a user