That's exactly what I need. I really hadn't seen that.

Thanks a lot

On Thursday, January 23, 2020 at 9:24:45 AM UTC+1, Hieronymus wrote:
>
> Hi
>
> I'm using the authorized_key module in my ansible user role.
> As some user aren't ssh key yet, I would like that by default this key is 
> not created and the task escaped.
> I've seen that the key string is required by this module.
> Is means that I cannot put a false default value?
>
> Here's my main task:
> [...]
> - name: "add public keys to users"
>   authorized_key:
>     user:       '{{ item.name  }}'
>     key:        '{{ item.ssh_key }}'
>   ignore_errors: yes
>   with_items:   '{{ user }}'
> [...]
>
>
> Here's the definition yaml file:
> [...]
> user:
>   - name:       'bob'
>     password:   "{{ bob_pass }}"
>     comment:    'Bob McKenzie'
>     uid:        '2000'
>     group:      'bob'
>     groups:     'wheel'
>     shell:      '/bin/bash'
>     state:      "{{ 'present' if bob_pass else 'absent' }}"
>     ssh_key:    "{{ bob_key | default(false) }}"
> [...]
>
>
> The bob_key is define in an another yaml variable file.
>
> Here's the error:
> [WARNING]: The value False (type bool) in a string field was converted to 
> 'False' (type string). If this does not look like what you expect, quote 
> the entire value to ensure it does not change.
>
>
> failed: [localhost] (item={'name': 'tzdkom', 'password': .....
> ..... "msg": "invalid key specified: False"}
>
>
> Is the variable ssh_key:    "{{ bob_key | *default(false)* }}"  wrong ?
> Could you please explain me this?
> Has someone an idea to bypass this problem when no ssh_key exist?
>
> Thanks and best regards,
> M.
>

-- 
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/06c59b3f-d25b-4d8d-9da9-a536a0593c5c%40googlegroups.com.

Reply via email to