Hello Todd, i try with easyrsa_clients.name but i see this error:
TASK [Probando salida]
*****************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an
undefined variable. The error was: 'list object' has no attribute
'name'\n\nThe error appears to be in
'/etc/ansible/openvpn/create_access_prod/playbook/list-test.yaml': line 6,
column 7, but may\nbe elsewhere in the file depending on the exact syntax
problem.\n\nThe offending line appears to be:\n\n tasks:\n - name:
\"Probando salida\"\n ^ here\n"}
PLAY RECAP
*****************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1
skipped=0 rescued=0 ignored=0
How can I use the name key in a with_items?
On Fri, Nov 11, 2022 at 11:24 PM Todd Lewis <[email protected]> wrote:
> You can't use "item" inside "with_items:" because "item" is being defined
> by "with_items:".
>
> Why don't you just use "client":
>
> - name: "Copy files
> copy:
> src: '{{ item.src }}'
> dest: '{{ item.dest }}'
> with_items:
> - { src: '{{ easyrsa_dest }}/easyrsa/pki/private/{{ client }}.key',
> dest: '{{ easyrsa_dest }}/keys' }
> - { src: '{{ easyrsa_dest }}/easyrsa/issued/{{ client }}.crt', dest: '{{
> easyrsa_dest }}/keys' }
>
> or "easyrsa_clients.name"?
>
> Or is there more to the problem that you've shown us?
>
> On 11/11/22 3:05 PM, SysAdmin EM wrote:
>
> Hello, I hope you can understand what I need, my english is not good, i
> still learning.
>
> I have a variable
>
> easyrsa_clients:
> - name: '{{ client }}'
>
> and this tasks:
>
> - name: "Copy files
> copy:
> src: '{{ item.src }}'
> dest: '{{ item.dest }}'
> with_items:
> - { src: '{{ easyrsa_dest }}/easyrsa/pki/private/{{ item.name
> }}.key', dest: '{{ easyrsa_dest }}/keys' }
> - { src: '{{ easyrsa_dest }}/easyrsa/issued/{{ item.name }}.crt',
> dest: '{{ easyrsa_dest }}/keys' }
>
> I need to be able to interact with the value of the variable
> easyrsa_clients within the parameter with_item.
>
> I think I should use easyrsa_clients.item.name but I don’t know.
>
> Any ideas??
>
> Regards
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAGUDtnnd9%3D2t1sv%2Bf_rbzXPOhRpcuaYnPFrhusFHy7yimLSMwg%40mail.gmail.com.