Last active
April 3, 2022 19:29
-
-
Save koichirok/3a2a0470a3c6095e8d8007fc98729775 to your computer and use it in GitHub Desktop.
ansible cannot store the externally obtained string "yes" as-is as "fact"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: host | |
hosts: localhost | |
gather_facts: false | |
tasks: | |
- block: | |
- name: show ansible version | |
ansible.builtin.debug: | |
var: ansible_version.full | |
- name: create "yes.txt" which content is "yes" | |
ansible.builtin.copy: | |
dest: "yes.txt" | |
content: "yes" | |
mode: 0644 | |
- name: load content of "yes.txt" | |
ansible.builtin.slurp: | |
path: "yes.txt" | |
register: slurped_yes | |
- name: show content of "yes.txt" | |
ansible.builtin.debug: | |
msg: "{{ slurped_yes.content | b64decode }}" | |
- name: set content of yes.txt as "should_be_string_yes" fact | |
ansible.builtin.set_fact: | |
should_be_string_yes: "{{ slurped_yes.content | b64decode }}" | |
- name: show value of "should_be_string_yes" fact | |
ansible.builtin.debug: | |
var: should_be_string_yes | |
- name: assert "should_be_string_yes" == "yes" | |
ansible.builtin.assert: | |
that: | |
- should_be_string_yes == "yes" | |
always: | |
- name: delete created "yes.txt" | |
ansible.builtin.file: | |
path: "yes.txt" | |
state: absent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Execution results with ansible 2.12.3: