Pages

Tuesday, 26 November 2019

EX294: Validate a working configuration using ad hoc Ansible commands

# Test connection with a password
$ ansible vm1 -i hosts --ask-pass -a 'uname -r'
SSH password:
vm1 | SUCCESS | rc=0 >>
3.10.0-1062.4.1.el7.x86_64

# Test a password-less connection
ansible vm1 -i hosts -a 'uname -r'
vm1 | SUCCESS | rc=0 >>
3.10.0-1062.4.1.el7.x86_64

# Test a "become" connection with a password
ansible vm1 -i hosts --become  --ask-become-pass -a 'whoami'
SUDO password:
vm1 | SUCCESS | rc=0 >>
root

# Test a password-less "become" connection
$ ansible vm1 -i hosts --become  -a 'whoami'
vm1 | SUCCESS | rc=0 >>

root

# Test a connection with login password and become password
$ ansible vm1 -i hosts --become --ask-pass --ask-become-pass  -a 'whoami'
SSH password:
SUDO password[defaults to SSH password]:
vm1 | SUCCESS | rc=0 >>
root

No comments:

Post a Comment