name: "Get the Authentication Token for the future requests"
ansible.builtin.uri:
url: "https://{{ controller_hostname }}/api/v2/tokens/"
user: "{{ controller_username }}"
password: "{{ controller_password }}"
method: POST
force_basic_auth: true
validate_certs: "{{ controller_validate_certs }}"
status_code: 201
register: authtoken_res
name: "Set the oauth token to be used since now"
ansible.builtin.set_fact:
controller_oauthtoken: "{{ authtoken_res.json.token }}"
controller_oauthtoken_url: "{{ authtoken_res.json.url }}"
no_log: "{{ controller_configuration_filetree_create_secure_logging | default('false') }}"
when: controller_oauthtoken is not defined
tags:
- error
No console error produced.
# STEPS TO REPRODUCE
run the following from the command line
` ansible-playbook playbooks/export_with_filetree.yml -i inventory.yml -e @keys.yml -vvvvv -e output_path=$PWD/Output/Path`
Summary
files output by the filetree_create have multiple document starts
---
and document ends...
See inventory_sources.yaml excerpt below.Issue Type
Ansible, Collection, Controller details
OS / ENVIRONMENT
WSL on Windows 11
NAME STATE VERSION
Desired Behavior
correctly formatted yaml documents preferably deduped.
Actual Behavior
Please give some details of what is actually happening. Include a [minimum complete verifiable example] with:
playbook / task
hosts: all connection: local gather_facts: false vars: controller_username: "{{ vault_controller_username | default(lookup('env', 'CONTROLLER_USERNAME')) }}" controller_password: "{{ vault_controller_password | default(lookup('env', 'CONTROLLER_PASSWORD')) }}" controller_hostname: "{{ vault_controller_hostname | default(lookup('env', 'CONTROLLER_HOST')) }}" controller_validate_certs: "{{ vault_controller_validate_certs | default(lookup('env', 'CONTROLLER_VERIFY_SSL')) }}"
pre_tasks:
name: "Setup authentication (block)" block:
name: "Get the Authentication Token for the future requests" ansible.builtin.uri: url: "https://{{ controller_hostname }}/api/v2/tokens/" user: "{{ controller_username }}" password: "{{ controller_password }}" method: POST force_basic_auth: true validate_certs: "{{ controller_validate_certs }}" status_code: 201 register: authtoken_res
name: "Set the oauth token to be used since now" ansible.builtin.set_fact: controller_oauthtoken: "{{ authtoken_res.json.token }}" controller_oauthtoken_url: "{{ authtoken_res.json.url }}" no_log: "{{ controller_configuration_filetree_create_secure_logging | default('false') }}" when: controller_oauthtoken is not defined tags:
always
roles:
post_tasks:
configuration file / list