Created
June 15, 2020 11:29
-
-
Save zeitounator/6168991050065ca2c371e99d8d91a2d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat inventory | |
--- | |
all: | |
children: | |
my_poc_hosts: | |
hosts: | |
target1: | |
target2: | |
target3: | |
# Undefined for hosts if no user given | |
$ $ ansible -i inventory all -m debug -a var=ansible_user | |
target1 | SUCCESS => { | |
"ansible_user": "VARIABLE IS NOT DEFINED!" | |
} | |
target2 | SUCCESS => { | |
"ansible_user": "VARIABLE IS NOT DEFINED!" | |
} | |
target3 | SUCCESS => { | |
"ansible_user": "VARIABLE IS NOT DEFINED!" | |
} | |
# Defined by default for locahost on local connection | |
$ ansible -i inventory localhost -m debug -a var=ansible_user | |
localhost | SUCCESS => { | |
"ansible_user": "my_user_obfuscated" | |
} | |
# Defined for hosts if given on command line | |
$ ansible -i inventory all -u toto -m debug -a var=ansible_user | |
target1 | SUCCESS => { | |
"ansible_user": "toto" | |
} | |
target2 | SUCCESS => { | |
"ansible_user": "toto" | |
} | |
target3 | SUCCESS => { | |
"ansible_user": "toto" | |
} | |
# .... and ok also with ask-pass ask-sudo-pass | |
$ ansible -i inventory all -kKu toto -m debug -a var=ansible_user | |
SSH password: | |
BECOME password[defaults to SSH password]: | |
target1 | SUCCESS => { | |
"ansible_user": "toto" | |
} | |
target2 | SUCCESS => { | |
"ansible_user": "toto" | |
} | |
target3 | SUCCESS => { | |
"ansible_user": "toto" | |
} | |
# Does not change for local connection even if you specify a different one | |
# Defined by default for locahost on local connection | |
$ ansible -i inventory localhost -m debug -u toto -a var=ansible_user | |
localhost | SUCCESS => { | |
"ansible_user": "my_user_obfuscated" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment