ansible playbook executing the tasks on localhost(Master Node) instead of remote node

395 views
Skip to first unread message

anilkumar panditi

unread,
Feb 4, 2020, 6:17:52 AM2/4/20
to Ansible Project
this is my dynamic inventory

# inventory of servers

#ungrouped servers
hdi_master1 ansible_host=13.234.186.61 ansible_user=centos --private-key=/home/centos/openshift.pem
#hdinsights groups
[hdinsights_all]
hdi_master1

My Playbook:
=================
# Playbook to configure kubernetes
- name: Install docker
  hosts: hdinsights_all
  become: true
  user: centos
  roles:
    - ansible-docker

My command: 
=============
ansible-playbook -i /root/ansible/config-mgmt/inventories/test_inventory.txt  k8s-playbook.yml -vvv

My ansible.cfg file:
=============
# some basic default values...
#inventory       = /etc/ansible/hosts
transport       = local
host_key_checking = False


when i run the playbook executing the tasks on localhost(Master Node) instead of remote node.
I was able to see the verbose output , its executing the tasks on localhost(Master Node) instead of remote node. like below.

ansible-playbook 2.9.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.6.8 (default, Aug  7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /root/ansible/config-mgmt/inventories/test_inventory.txt as it did not pass its verify_file() method
auto declined parsing /root/ansible/config-mgmt/inventories/test_inventory.txt as it did not pass its verify_file() method
yaml declined parsing /root/ansible/config-mgmt/inventories/test_inventory.txt as it did not pass its verify_file() method
Parsed /root/ansible/config-mgmt/inventories/test_inventory.txt inventory source with ini plugin
statically imported: /root/ansible/config-mgmt/roles/ansible-docker/tasks/docker-1809-shim.yml

PLAYBOOK: k8s-playbook.yml *****************************************************
1 plays in k8s-playbook.yml

PLAY [Install docker] **********************************************************

TASK [Gathering Facts] *********************************************************
task path: /root/ansible/config-mgmt/playbooks/k8s-playbook.yml:2
<13.234.186.61> ESTABLISH LOCAL CONNECTION FOR USER: root
<13.234.186.61> EXEC /bin/sh -c 'echo ~root && sleep 0'
<13.234.186.61> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1580810951.5062504-273966357242253 `" && echo ansible-tmp-1580810951.5062504-273966357242253="` echo /root/.ansible/tmp/ansible-tmp-1580810951.5062504-273966357242253 `" ) && sleep 0'
<hdi_master1> Attempting python interpreter discovery
<13.234.186.61> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<13.234.186.61> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/system/setup.py
<13.234.186.61> PUT /root/.ansible/tmp/ansible-local-105940rpdscio/tmpdm6lega7 TO /root/.ansible/tmp/ansible-tmp-1580810951.5062504-273966357242253/AnsiballZ_setup.py
<13.234.186.61> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1580810951.5062504-273966357242253/ /root/.ansible/tmp/ansible-tmp-1580810951.5062504-273966357242253/AnsiballZ_setup.py && sleep 0'
<13.234.186.61> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1580810951.5062504-273966357242253/AnsiballZ_setup.py && sleep 0'
<13.234.186.61> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1580810951.5062504-273966357242253/ > /dev/null 2>&1 && sleep 0'
ok: [hdi_master1]
META: ran handlers

TASK [ansible-docker : include_tasks] ******************************************
task path: /root/ansible/config-mgmt/roles/ansible-docker/tasks/main.yml:2
included: /root/ansible/config-mgmt/roles/ansible-docker/tasks/setup-RedHat.yml for hdi_master1

TASK [ansible-docker : Ensure old versions of Docker are not installed.] *******
task path: /root/ansible/config-mgmt/roles/ansible-docker/tasks/setup-RedHat.yml:2
<13.234.186.61> ESTABLISH LOCAL CONNECTION FOR USER: root
<13.234.186.61> EXEC /bin/sh -c 'echo ~root && sleep 0'
<13.234.186.61> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1580810953.4665756-103093794955295 `" && echo ansible-tmp-1580810953.4665756-103093794955295="` echo /root/.ansible/tmp/ansible-tmp-1580810953.4665756-103093794955295 `" ) && sleep 0'
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/packaging/os/yum.py
<13.234.186.61> PUT /root/.ansible/tmp/ansible-local-105940rpdscio/tmpdacflhwm TO /root/.ansible/tmp/ansible-tmp-1580810953.4665756-103093794955295/AnsiballZ_yum.py
<13.234.186.61> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1580810953.4665756-103093794955295/ /root/.ansible/tmp/ansible-tmp-1580810953.4665756-103093794955295/AnsiballZ_yum.py && sleep 0'
<13.234.186.61> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1580810953.4665756-103093794955295/AnsiballZ_yum.py && sleep 0'
<13.234.186.61> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1580810953.4665756-103093794955295/ > /dev/null 2>&1 && sleep 0'
ok: [hdi_master1] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_downgrade": false,
            "autoremove": false,
            "bugfix": false,
            "conf_file": null,
            "disable_excludes": null,
            "disable_gpg_check": false,
            "disable_plugin": [],
            "disablerepo": [],
            "download_dir": null,
            "download_only": false,
            "enable_plugin": [],
            "enablerepo": [],
            "exclude": [],
            "install_repoquery": true,
            "install_weak_deps": true,
            "installroot": "/",
            "list": null,
            "lock_timeout": 30,
            "name": [
                "docker",
                "docker-common",
                "docker-engine"
            ],
            "releasever": null,
            "security": false,
            "skip_broken": false,
            "state": "absent",
            "update_cache": false,
            "update_only": false,
            "use_backend": "auto",
            "validate_certs": true
        }
    },
    "msg": "",
    "rc": 0,
    "results": [
        "docker is not installed",
        "docker-common is not installed",
        "docker-engine is not installed"
    ]
}

TASK [ansible-docker : Add Docker GPG key.] ************************************
task path: /root/ansible/config-mgmt/roles/ansible-docker/tasks/setup-RedHat.yml:10
<13.234.186.61> ESTABLISH LOCAL CONNECTION FOR USER: root
<13.234.186.61> EXEC /bin/sh -c 'echo ~root && sleep 0'
<13.234.186.61> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1580810954.2718413-150436624758806 `" && echo ansible-tmp-1580810954.2718413-150436624758806="` echo /root/.ansible/tmp/ansible-tmp-1580810954.2718413-150436624758806 `" ) && sleep 0'
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/packaging/os/rpm_key.py
<13.234.186.61> PUT /root/.ansible/tmp/ansible-local-105940rpdscio/tmpn6b86fhm TO /root/.ansible/tmp/ansible-tmp-1580810954.2718413-150436624758806/AnsiballZ_rpm_key.py
<13.234.186.61> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1580810954.2718413-150436624758806/ /root/.ansible/tmp/ansible-tmp-1580810954.2718413-150436624758806/AnsiballZ_rpm_key.py && sleep 0'
<13.234.186.61> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1580810954.2718413-150436624758806/AnsiballZ_rpm_key.py && sleep 0'
<13.234.186.61> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1580810954.2718413-150436624758806/ > /dev/null 2>&1 && sleep 0'
ok: [hdi_master1] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "fingerprint": null,
            "state": "present",
            "validate_certs": true
        }
    }
}




Jordan Borean

unread,
Feb 4, 2020, 6:43:35 AM2/4/20
to Ansible Project
It’s because you have transport=local in your ansible.cfg. Remove that and it will default to ssh.
Reply all
Reply to author
Forward
0 new messages