You can do like this :
Add a new "hosts" section in your playbook
- hosts: all
tasks:
[...]
- hosts: your_specific_host
vars:
ansible_user: your_username
tasks:
[...]
- hosts: all
vars:
[...]
tasks:
[...]
Regards,
C.G.
Le lundi 11 décembre 2017 20:28:06 UTC+1, Kevin Phillips a écrit :
>
> Hi all. I was redirected here from the Ansible issue tracker on Github. I
> am having difficulties with a specific use case I'm hoping to get help with.
>
> I am trying to find a way to programatically change SSH credentials in an
> Ansible play between tasks and / or between hosts. Here is my most basic
> use case: When bootstrapping a new server that has no LDAP configuration,
> user profiles, etc. I need to authenticate as root. However, in the first
> play I want to set up a limited user with sudo permissions (presumably
> while logged in as root), then I want to disable remote logins for root and
> continue running the rest of the plays as my newly created user.
>
> For bootstrapping purposes, the root users typically just have password
> enabled authentication using a known default password... however the user
> created by this first play is being configured with an SSH key to
> facilitate passwordless logins for the remainder of the plays.
>
> Can someone tell me how I might orchestrate this seemingly simple sequence
> of events? I've read up on ssh_args, ansible_pass, remote_user, and many
> other ways of defining credentials for tasks but none of them seem to allow
> the modification of the user and password in the way I've described above.
> So any help / suggestions anyone has in this regard would be appreciated.
>
> We run our ansible plays on various Linux OSes and Mac OS X, and we're
> using the latest version of Ansible in case that helps at all.
>
>
--
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/7ad50427-8372-4803-82c3-42da0a1a31ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.