On Wed, Aug 19, 2020 at 7:34 AM John Petro <
jcp...@johnpetro.com> wrote:
>
> Do you have ssh keys set up between the ansible control node and the host you are running this against? If not, you need to specify the username and password as well. -u is the switch for user and then you would need -k or - Kk as well, depending on whether you have sudoers set up to allow you to execute passwordless root access or not.
>
Elaborating on what John said,
1. Try something like
ansible secured -m setup
Get the above running first. As he said, you may need to do something like
ansible secured -k -m setup
if you are not using ssh keypairs and/or
ansible secured -u USERNAME -k -m setup
if the login user is not the user you are running as (plus password).
2. If that works,
ansible --become -k -K secured -m shell -a "sudo pwd"
(adding user or not as needed based on results from previous step)
3. If the above works, here is the config file for my testubuntu box:
raub@desktop:~/dev/ansible$ cat host_vars/testubuntu.yml
---
# File: host_vars/testubuntu.yml
#
ansible_host:
testubuntu.example.com
ansible_port: 2026
ansible_ssh_private_key_file: keys/ubuntu-test
ansible_user: root
raub@desktop:~/dev/ansible$
Yes, I put a pub key in root so I can avoid needing to use a password.
Whether this make sense or not in your setup is up to you, but the
point is that I know I have those 4 variables defined and where to
check them.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAPAjob_DgL%3DBRHdq%2BboDyUoaonG_iaj-JG%2B_Wdx1TVUQk8LJkQ%40mail.gmail.com.