Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - name: test_playbook
- hosts: localhost
- connection: local
- vars:
- server__fqdn: myserver.local
- server__team: superduper_team
- request_body:
- matchers: |
- {% filter from_yaml %}
- {% if "myserver" in server__fqdn %}
- - name: "host"
- value: "{{ server__fqdn }}"
- type: "EQUAL"
- - name: "node"
- value: "myserver"
- type: "EQUAL"
- {% else %}
- - name: "host"
- value: "{{ server__fqdn }}"
- type: "EQUAL"
- {% endif %}
- {% endfilter %}
- teamName: "{{ server__team }}"
- tasks:
- - debug:
- var: request_body|type_debug
- - debug:
- var: request_body
- - debug:
- var: request_body|to_json
- OUTPUT:
- ansible-playbook playbooks/test.yml
- /usr/local/lib/python3.7/site-packages/paramiko/transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated
- "class": algorithms.Blowfish,
- [WARNING]: No inventory was parsed, only implicit localhost is available
- PLAY [test_playbook] ****************************************************************************************************************************
- TASK [Gathering Facts] **************************************************************************************************************************
- пятница 20 октября 2023 16:30:14 +0300 (0:00:00.013) 0:00:00.013 *******
- ok: [localhost]
- TASK [debug] ************************************************************************************************************************************
- пятница 20 октября 2023 16:30:15 +0300 (0:00:00.911) 0:00:00.924 *******
- fatal: [localhost]: FAILED! =>
- msg: |-
- An unhandled exception occurred while templating '{'matchers': '{% filter from_yaml %}\n{% if "myserver" in server__fqdn %}\n- name: "host"\n value: "{{ server__fqdn }}"\n type: "EQUAL"\n- name: "node"\n value: "myserver"\n type: "EQUAL"\n{% else %}\n- name: "host"\n value: "{{ server__fqdn }}"\n type: "EQUAL"\n{% endif %}\n{% endfilter %}\n', 'teamName': '{{ server__team }}'}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Unexpected templating type error occurred on ({% filter from_yaml %}
- {% if "myserver" in server__fqdn %}
- - name: "host"
- value: "{{ server__fqdn }}"
- type: "EQUAL"
- - name: "node"
- value: "myserver"
- type: "EQUAL"
- {% else %}
- - name: "host"
- value: "{{ server__fqdn }}"
- type: "EQUAL"
- {% endif %}
- {% endfilter %}
- ): sequence item 0: expected str instance, list found
- PLAY RECAP **************************************************************************************************************************************
- localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
- пятница 20 октября 2023 16:30:15 +0300 (0:00:00.040) 0:00:00.965 *******
- ===============================================================================
- Gathering Facts -------------------------------------------------------------------------------------------------------------------------- 0.91s
- debug ------------------------------------------------------------------------------------------------------------------------------------ 0.04s
- ansible --version
- /usr/local/lib/python3.7/site-packages/paramiko/transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated
- "class": algorithms.Blowfish,
- ansible [core 2.11.12]
- config file = /Users/username/projects/ansible.cfg
- configured module search path = ['/Users/username/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
- ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
- ansible collection location = /Users/username/projects:/Users/username/.ansible/collections
- executable location = /usr/local/bin/ansible
- python version = 3.7.12 (default, Oct 22 2021, 17:50:30) [Clang 13.0.0 (clang-1300.0.29.3)]
- jinja version = 3.1.2
- libyaml = True
Advertisement
Add Comment
Please, Sign In to add comment