ansible for config management and deployment

I am following along with the video Lecture: The 'Apt' Module. After doing a key exchange I can still unable to gather facts on the remote ubuntu server from my centos control server even though I can ssh across those servers without a password, I still get this error when running my playbook:

Please let me know what I am missing. Thanks.

TASK [Gathering Facts] ***************************************************************************************************************************************************************************************************************

fatal: []: FAILED! => {"changed": false, "module_stderr": "Shared connection to closed.\r\n", "module_stdout": "sudo: a password is required\r\n", "msg": "MODULE FAILURE\nSee stdout/s

tderr for the exact error", "rc": 1}

--- # Apt module example

- hosts: aptserver

user: test

become: yes

connection: ssh #instead of paramiko

gather_facts: yes # gather once with yes


- name: Install apache web server

apt: name=apache2 state=present

  • post-author-pic
    Terrence C

    Two things:

    1. Be sure you exchanged SSH keys for the user you are executing the playbook as (test user in this case), even if you are starting the playbook as a different user.
    2. Make sure your ansible configuration is not configured to prompt for password

    I suspect #1

  • post-author-pic
    Benjamin C

    Hi Terrence, I am able to ssh from my centos control server to ubuntu and vice versa as the test user. That would imply that I did the key exchange for the test user correctly right?

    test@bcheng5:~$ ssh bcheng1

    Last login: Wed Jan 9 03:50:53 2019 from

    [test@bcheng1 ~]$ ssh bcheng5

    Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-1072-aws x86_64)

    * Documentation:

    * Management:

    * Support:

    Get cloud support with Ubuntu Advantage Cloud Guest:

    48 packages can be updated.

    24 updates are security updates.

    New release '18.04.1 LTS' available.

    Run 'do-release-upgrade' to upgrade to it.

    Last login: Wed Jan 9 03:50:47 2019 from


Looking For Team Training?

Learn More