There are some ansible config values that can control where the
ControlPath file is created and the remote temporary path but overall
it may be easier to use the shell module on localhost for this
- hosts: all
vars:
- new_username: badger
gather_facts: no
tasks:
- name: Auto generate user home directory
command: ssh {{ new_username }}@{{ inventory_hostname }} /usr//bin/whoami
delegate_to: localhost
Note that the above playbook assumes that your inventory_hostnames are
all resolvable to real hostnames. If that's not the case you may need
to make some modifications (for instance, create a group in the
inventory that contains the resolvable hostnames of the machines
you're interested in and use that group in the hosts: field)
-Toshio
On Thu, Nov 13, 2014 at 10:09 AM, <[email protected]> wrote:
> I have a virtual machine that when first login as a user, it will create the
> home directory for the user if it doesn't have one.
>
> So just sth like,
> $ ssh username@myhostname
> $ Creating directory '/home/username'.
>
> How could I use Ansible to do that(just login in order to generate a home
> directory)?
>
> I tried this in playbook:
> ---
> - hosts: all
> gather_facts: no
> remote_user: theusername
> tasks:
> - name: Auto generate user home directory
> shell: /usr/bin/whoami
>
> It threw an exception saying "ControlPath too long". But when I do the same
> thing with a user that has a home directory in the machine, it will succeed.
> The control path is:
> 'ControlPath=/net/myhostname/userhome/myusername/.ansible/cp/ansible-ssh-%h-%p-%r'
>
> --
> 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/228dc9ac-d213-4afb-a3c1-6fffec6b06a9%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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/CAG9juEr91s-mQP3QtVd%3D4acXOS6J1E4nH4uqBV_mk9SwWjvPFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.