Add files via upload

This commit is contained in:
kneutron 2022-04-20 19:41:13 -05:00 committed by GitHub
parent 6db8e9f9e4
commit 36ca496c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,3 @@
#!/bin/bash
ansible-playbook -i localhost demo-ansible-lowercase-search-replace.yml

View 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 }}"