[Solved] How to separate the output of register into dict

I create the dict vmoff2 using the following: – name: create Not Activated VM list set_fact: vmoff: >- {{ vmoff | default([]) + [{ ‘sec_sys’: item.item.SEC_SYS, ‘vm_na’: dict(item.stdout_lines | from_yaml | select() | map(‘split’, ‘,’) | list) }] }} loop: “{{ output.results }}” loop_control: label: “{{ item.item.SEC_SYS }}” And eliminate the duplicate output with: – … Read more

[Solved] copy files to remote servers but in a directory which belongs to some other user?

Since you hint on having sudo configured for your connecting user david, the simplest thing you can do is use elevated permissions to copy the file and set its an ownership to goldy through owner parameter of the unarchive module: – name: copy and untar latest tasks.tar.gz file unarchive: src: tasks.tar.gz dest: /data/files/tasks/ owner: goldy … Read more

[Solved] ansible, jinja template with loops, losing newlines [duplicate]

And this little change actually made the problem go away in the end. #jinja2: trim_blocks:False { “Users”: [ {% for username,user in _vpn_user_accounts.items() %} { “Name” : “{{ user.name }}”, “Hash” : “{{ user.hash }}”, “Cns” : [ {%- for cn in user.cns.get(server_name, []) %} “{{ cn }}”{% if not loop.last -%},{% endif %} {%- … Read more

[Solved] How can i use variables in ansible playbook?

You can use variable in ansible playbook like: – name: Create Directory file: path: “{{ directory_path }}” state: directory mode: 0755 become: yes In ansible you put the variable in double curly braces. in the above example directory_path is a variable. you can read about ansible variables here. 0 solved How can i use variables … Read more