ansible vs. ansible-playbook re: where they get their config

14 views
Skip to first unread message

Ed Wong

unread,
Jul 31, 2020, 4:42:22 AM7/31/20
to Ansible Project
I'm using ansible 2.9.11 w/ python3.8   I've ssh'd into my ansible control box via putty from a Windows box. I have set Agent forwarding to true.

I have the following ansible_host:

all:
    hosts:
        127.0.0.1:
        lister:
            ansible_host: lister.rd.local

This is in my ansible.cfg:

[defaults]
inventory = /home/ewong/infra/conf/ansible_hosts

remote_user = infra
private_key_file = /home/ewong/.ssh/id_infra


Now, I have a playbook:

---
- hosts: lister
  remote_user: root
  tasks:
    - name: install bind
      package:
        name: bind
        state: present


if I run "ansible lister -m ping", I get:

lister | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}


but if I run "ansible-playbook inst_bind.yml",  I get:

PLAY [lister] ********************************************************************

TASK [Gathering Facts] *********************************************************
fatal: [lister]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}

PLAY RECAP *********************************************************************
lister                       : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0


So I try  "ansible-playbook inst_bind.yml --private-key ~/.ssh/id_infra", but I still get the above error.

I ran "ansible-lint inst_bind.yml", but I get no errors.

Have I misconfigured something?

Thanks

Ed
Reply all
Reply to author
Forward
0 new messages