Hello gentle people,
I think being able to register the output of commands/modules as host
variables will be very useful.
I got this idea writing a playbook to do;
1. create a root user key pair for a couple hosts
2. authorizing the root user public key of all hosts to connect to all
other hosts.
My approach is to use the 'user' module to create generate the key pair,
then use the output
of the user module for each host as the key parameter to the
'authorized_key' module.
- name: generate SSH key pair for root user
user:
name: root
generate_ssh_key: yes
ssh_key_comment: "{{inventory_hostname}}"
register: root_key
- name: add authorized keys for root
authorized_key:
user: root
key: "{{hostvars[item]['root_key']['ssh_public_key']}}"
with_items: groups['allservers']
Unless I am not using 'register' right. The above obviously failed because
register can not be
associated with the host on which the module run. This will definitely be a
good thing to have.
Any thoughts on my approach to generating and authorizing key pairs for all
hosts?
Is the ability to register module output like a host variable useful or can
such be accomplished by
other means?
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b7889e8c-289a-42e5-b59b-bdb57616d752%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.