在Ansible中,如果遇到容器中的无效字符%,有两种解决方法:
- name: Example playbook
hosts: localhost
tasks:
- name: Example task
shell: echo "The percentage sign is %%"
- name: Example playbook
hosts: localhost
tasks:
- name: Example task
shell: echo "The percentage sign is {{ '%' }}"
这样,Jinja2会将{{ '%' }}解析为百分号,并将其传递给Ansible。