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: [bcheng5.mylabserver.com]: FAILED! => {"changed": false, "module_stderr": "Shared connection to bcheng5.mylabserver.com 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

tasks:

- name: Install apache web server

apt: name=apache2 state=present


  • post-author-pic
    Terrence C
    12-31-2018

    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
    01-09-2019

    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 ec2-18-237-121-20.us-west-2.compute.amazonaws.com

    [test@bcheng1 ~]$ ssh bcheng5

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

    * Documentation: https://help.ubuntu.com

    * Management: https://landscape.canonical.com

    * Support: https://ubuntu.com/advantage

    Get cloud support with Ubuntu Advantage Cloud Guest:

    http://www.ubuntu.com/business/services/cloud

    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 34.215.44.19

    test@bcheng5:~$ 


Looking For Team Training?

Learn More