Ansible managed host issue

1,479 views
Skip to first unread message

Orkhan Mammadov

unread,
Apr 12, 2020, 1:54:54 PM4/12/20
to Ansible Project
Hi guys,

Could you please help me regarding to the following issue?

I have setup a control host and 2 managed host, IP Addresses are static and dns is over /etc/hosts file. SSH Keygen is created and copied to managed hosts and I can ssh to managed host without password.

Ansible installed:

[ansible@control install]$ ansible --version
ansible 2.9.6
  config file = /home/ansible/install/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ansible/.local/lib/python3.6/site-packages/ansible
  executable location = /home/ansible/.local/bin/ansible
  python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]

Note: ansible1 and ansible2 are managed hosts.

When I add command -  ansible all -m user -a "name=lisa"- it gives the following message:

ansible2 | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "msg": "useradd: Permission denied.\nuseradd: cannot lock /etc/passwd; try again later.\n",
    "name": "lisa",
    "rc": 1
}
ansible1 | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "msg": "useradd: Permission denied.\nuseradd: cannot lock /etc/passwd; try again later.\n",
    "name": "lisa",
    "rc": 1

It took me a lot of time to find solution, but could not find anything. Is anyone faced with this error message


Stefan Hornburg (Racke)

unread,
Apr 12, 2020, 2:12:28 PM4/12/20
to ansible...@googlegroups.com
On 4/12/20 7:54 PM, Orkhan Mammadov wrote:
> Hi guys,
>
> Could you please help me regarding to the following issue?
>
> I have setup a control host and 2 managed host, IP Addresses are static and dns is over /etc/hosts file. SSH Keygen is
> created and copied to managed hosts and I can ssh to managed host without password.

You need to be superuser (root) on the managed hosts to create new users.

Add -b (--become) and if applicable -K (--ask-become-pass) to your command line.

Regards
Racke

>
> Ansible installed:
>
> *[ansible@control install]$ ansible --version*
> *ansible 2.9.6*
> *  config file = /home/ansible/install/ansible.cfg*
> *  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']*
> *  ansible python module location = /home/ansible/.local/lib/python3.6/site-packages/ansible*
> *  executable location = /home/ansible/.local/bin/ansible*
> *  python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]*
>
> Note: _ansible1_ and _ansible2 _are managed hosts.
>
> When I add command -  ansible all -m user -a "name=lisa"- it gives the following message:
> *
> *
> *ansible2 | FAILED! => {*
> *    "ansible_facts": {*
> *        "discovered_interpreter_python": "/usr/bin/python"*
> *    },*
> *    "changed": false,*
> *    "msg": "useradd: Permission denied.\nuseradd: cannot lock /etc/passwd; try again later.\n",*
> *    "name": "lisa",*
> *    "rc": 1*
> *}*
> *ansible1 | FAILED! => {*
> *    "ansible_facts": {*
> *        "discovered_interpreter_python": "/usr/bin/python"*
> *    },*
> *    "changed": false,*
> *    "msg": "useradd: Permission denied.\nuseradd: cannot lock /etc/passwd; try again later.\n",*
> *    "name": "lisa",*
> *    "rc": 1*
>
> It took me a lot of time to find solution, but could not find anything. Is anyone faced with this error message
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4c947533-b4cc-44aa-a501-9602c8eb3438%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/4c947533-b4cc-44aa-a501-9602c8eb3438%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Orkhan Mammadov

unread,
Apr 12, 2020, 2:42:52 PM4/12/20
to Ansible Project
It worked, gr8 thanks. I am new in ansible and learning with Sanders's RHCE video course.
Reply all
Reply to author
Forward
0 new messages