如何解决使用 Ansible 将其内容添加到文件时,如何避免包含变量的双引号?
我正在运行 ansible playbook,它基本上是在远程 Linux 服务器上执行脚本并将生成的哈希保存到变量中,以便稍后添加到同一服务器上的不同文件中,如下所示:
tasks:
- name: Hash the new password in
expect:
command: bash /path/hash.sh
responses:
Password: "{{awd}}"
register: command_output
- name: store the hash value into variable
set_fact:
string_to_echo: "{{ command_output.stdout_lines[-1]}}"
- name: Update sg_internal_users file
become: true
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK msa_number"
path: /'path'/
backup: yes
block: |
hash: "{{string_to_echo}}"
问题是变量的值被附加了两个双引号,而我只需要存储哈希值而没有其他内容。
预期:
哈希:dgerggghergerthe
结果:
哈希:“dgerggghergergerthe”
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。