ansible - playbook execution fails for user creation with permission issue












0















I am new to devops and tried puppet out for sometime and now checking on ansible.
I have setup the ansible in the conventional ways like described on most of the tutorials
1> downloaded EPL
2> installed ansible
3> exchanged the ssh keys between control and target machines.
4> configured the sshd_conf file properly



Now its time for me to test the ping with below




sudo ansible testservers -u admin -m ping




but when i do that i get a output as below



ansible 2.6.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.6.6 (r266:84292, Aug 9 2016, 06:11:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
META: ran handlers
<admin@10.0.0.47> ESTABLISH SSH CONNECTION FOR USER: admin
<admin@10.0.0.47> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/bbbace40d6 admin@10.0.0.47 '/bin/sh -c '"'"'echo ~admin && sleep 0'"'"''
<admin@10.0.0.47> (255, '', 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn')
admin@10.0.0.47 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn",
"unreachable": true
}


But when I do it with --ask-pas like below and supply the password, then it works fine ( which is not useful when automating)



sudo ansible testservers -m user -a'name=vasanth state=absent' --become --ask-pas
SSH password:
admin@10.0.0.47 | SUCCESS => {
"changed": false,
"name": "vasanth",
"state": "absent"
}


For solving this, i Added the "ansible_ssh_pass" in /etc/ansible/hosts file and it was solved. ping was success without --ask-pas



Now next step is to execute playbooks
I created a playbook like below



 hosts: all
tasks:
- name: Ansible create user example.
user:
name: vasanth
password: vasanth


when i execute i get the below result



    sudo ansible-playbook userCreate.yml -v
Using /etc/ansible/ansible.cfg as config file

PLAY [all] ************************************************************************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************************************************
ok: [10.0.0.47]

TASK [Ansible create user example.] ***********************************************************************************************************************************************************
fatal: [10.0.0.47]: FAILED! => {"changed": false, "cmd": "/usr/sbin/useradd -p VALUE_SPECIFIED_IN_NO_LOG_PARAMETER -m VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "msg": "[Errno 13] Permission denied", "rc": 13}
to retry, use: --limit @/home/admin/userCreate.retry

PLAY RECAP ************************************************************************************************************************************************************************************
10.0.0.47 : ok=1 changed=0 unreachable=0 failed=1


what is the problem here?










share|improve this question



























    0















    I am new to devops and tried puppet out for sometime and now checking on ansible.
    I have setup the ansible in the conventional ways like described on most of the tutorials
    1> downloaded EPL
    2> installed ansible
    3> exchanged the ssh keys between control and target machines.
    4> configured the sshd_conf file properly



    Now its time for me to test the ping with below




    sudo ansible testservers -u admin -m ping




    but when i do that i get a output as below



    ansible 2.6.2
    config file = /etc/ansible/ansible.cfg
    configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
    ansible python module location = /usr/lib/python2.6/site-packages/ansible
    executable location = /usr/bin/ansible
    python version = 2.6.6 (r266:84292, Aug 9 2016, 06:11:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
    Using /etc/ansible/ansible.cfg as config file
    Parsed /etc/ansible/hosts inventory source with ini plugin
    META: ran handlers
    <admin@10.0.0.47> ESTABLISH SSH CONNECTION FOR USER: admin
    <admin@10.0.0.47> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/bbbace40d6 admin@10.0.0.47 '/bin/sh -c '"'"'echo ~admin && sleep 0'"'"''
    <admin@10.0.0.47> (255, '', 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn')
    admin@10.0.0.47 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn",
    "unreachable": true
    }


    But when I do it with --ask-pas like below and supply the password, then it works fine ( which is not useful when automating)



    sudo ansible testservers -m user -a'name=vasanth state=absent' --become --ask-pas
    SSH password:
    admin@10.0.0.47 | SUCCESS => {
    "changed": false,
    "name": "vasanth",
    "state": "absent"
    }


    For solving this, i Added the "ansible_ssh_pass" in /etc/ansible/hosts file and it was solved. ping was success without --ask-pas



    Now next step is to execute playbooks
    I created a playbook like below



     hosts: all
    tasks:
    - name: Ansible create user example.
    user:
    name: vasanth
    password: vasanth


    when i execute i get the below result



        sudo ansible-playbook userCreate.yml -v
    Using /etc/ansible/ansible.cfg as config file

    PLAY [all] ************************************************************************************************************************************************************************************

    TASK [Gathering Facts] ************************************************************************************************************************************************************************
    ok: [10.0.0.47]

    TASK [Ansible create user example.] ***********************************************************************************************************************************************************
    fatal: [10.0.0.47]: FAILED! => {"changed": false, "cmd": "/usr/sbin/useradd -p VALUE_SPECIFIED_IN_NO_LOG_PARAMETER -m VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "msg": "[Errno 13] Permission denied", "rc": 13}
    to retry, use: --limit @/home/admin/userCreate.retry

    PLAY RECAP ************************************************************************************************************************************************************************************
    10.0.0.47 : ok=1 changed=0 unreachable=0 failed=1


    what is the problem here?










    share|improve this question

























      0












      0








      0








      I am new to devops and tried puppet out for sometime and now checking on ansible.
      I have setup the ansible in the conventional ways like described on most of the tutorials
      1> downloaded EPL
      2> installed ansible
      3> exchanged the ssh keys between control and target machines.
      4> configured the sshd_conf file properly



      Now its time for me to test the ping with below




      sudo ansible testservers -u admin -m ping




      but when i do that i get a output as below



      ansible 2.6.2
      config file = /etc/ansible/ansible.cfg
      configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
      ansible python module location = /usr/lib/python2.6/site-packages/ansible
      executable location = /usr/bin/ansible
      python version = 2.6.6 (r266:84292, Aug 9 2016, 06:11:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
      Using /etc/ansible/ansible.cfg as config file
      Parsed /etc/ansible/hosts inventory source with ini plugin
      META: ran handlers
      <admin@10.0.0.47> ESTABLISH SSH CONNECTION FOR USER: admin
      <admin@10.0.0.47> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/bbbace40d6 admin@10.0.0.47 '/bin/sh -c '"'"'echo ~admin && sleep 0'"'"''
      <admin@10.0.0.47> (255, '', 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn')
      admin@10.0.0.47 | UNREACHABLE! => {
      "changed": false,
      "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn",
      "unreachable": true
      }


      But when I do it with --ask-pas like below and supply the password, then it works fine ( which is not useful when automating)



      sudo ansible testservers -m user -a'name=vasanth state=absent' --become --ask-pas
      SSH password:
      admin@10.0.0.47 | SUCCESS => {
      "changed": false,
      "name": "vasanth",
      "state": "absent"
      }


      For solving this, i Added the "ansible_ssh_pass" in /etc/ansible/hosts file and it was solved. ping was success without --ask-pas



      Now next step is to execute playbooks
      I created a playbook like below



       hosts: all
      tasks:
      - name: Ansible create user example.
      user:
      name: vasanth
      password: vasanth


      when i execute i get the below result



          sudo ansible-playbook userCreate.yml -v
      Using /etc/ansible/ansible.cfg as config file

      PLAY [all] ************************************************************************************************************************************************************************************

      TASK [Gathering Facts] ************************************************************************************************************************************************************************
      ok: [10.0.0.47]

      TASK [Ansible create user example.] ***********************************************************************************************************************************************************
      fatal: [10.0.0.47]: FAILED! => {"changed": false, "cmd": "/usr/sbin/useradd -p VALUE_SPECIFIED_IN_NO_LOG_PARAMETER -m VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "msg": "[Errno 13] Permission denied", "rc": 13}
      to retry, use: --limit @/home/admin/userCreate.retry

      PLAY RECAP ************************************************************************************************************************************************************************************
      10.0.0.47 : ok=1 changed=0 unreachable=0 failed=1


      what is the problem here?










      share|improve this question














      I am new to devops and tried puppet out for sometime and now checking on ansible.
      I have setup the ansible in the conventional ways like described on most of the tutorials
      1> downloaded EPL
      2> installed ansible
      3> exchanged the ssh keys between control and target machines.
      4> configured the sshd_conf file properly



      Now its time for me to test the ping with below




      sudo ansible testservers -u admin -m ping




      but when i do that i get a output as below



      ansible 2.6.2
      config file = /etc/ansible/ansible.cfg
      configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
      ansible python module location = /usr/lib/python2.6/site-packages/ansible
      executable location = /usr/bin/ansible
      python version = 2.6.6 (r266:84292, Aug 9 2016, 06:11:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
      Using /etc/ansible/ansible.cfg as config file
      Parsed /etc/ansible/hosts inventory source with ini plugin
      META: ran handlers
      <admin@10.0.0.47> ESTABLISH SSH CONNECTION FOR USER: admin
      <admin@10.0.0.47> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/bbbace40d6 admin@10.0.0.47 '/bin/sh -c '"'"'echo ~admin && sleep 0'"'"''
      <admin@10.0.0.47> (255, '', 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn')
      admin@10.0.0.47 | UNREACHABLE! => {
      "changed": false,
      "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn",
      "unreachable": true
      }


      But when I do it with --ask-pas like below and supply the password, then it works fine ( which is not useful when automating)



      sudo ansible testservers -m user -a'name=vasanth state=absent' --become --ask-pas
      SSH password:
      admin@10.0.0.47 | SUCCESS => {
      "changed": false,
      "name": "vasanth",
      "state": "absent"
      }


      For solving this, i Added the "ansible_ssh_pass" in /etc/ansible/hosts file and it was solved. ping was success without --ask-pas



      Now next step is to execute playbooks
      I created a playbook like below



       hosts: all
      tasks:
      - name: Ansible create user example.
      user:
      name: vasanth
      password: vasanth


      when i execute i get the below result



          sudo ansible-playbook userCreate.yml -v
      Using /etc/ansible/ansible.cfg as config file

      PLAY [all] ************************************************************************************************************************************************************************************

      TASK [Gathering Facts] ************************************************************************************************************************************************************************
      ok: [10.0.0.47]

      TASK [Ansible create user example.] ***********************************************************************************************************************************************************
      fatal: [10.0.0.47]: FAILED! => {"changed": false, "cmd": "/usr/sbin/useradd -p VALUE_SPECIFIED_IN_NO_LOG_PARAMETER -m VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "msg": "[Errno 13] Permission denied", "rc": 13}
      to retry, use: --limit @/home/admin/userCreate.retry

      PLAY RECAP ************************************************************************************************************************************************************************************
      10.0.0.47 : ok=1 changed=0 unreachable=0 failed=1


      what is the problem here?







      ansible






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 11:25









      Vasanth Nag K VVasanth Nag K V

      1,48641434




      1,48641434
























          2 Answers
          2






          active

          oldest

          votes


















          2














          If you're not connecting to the remote host as root, then you need to tell Ansible to become root when running your tasks using the become: key, which can be placed on a play to run all tasks in that play with elevated privileges:



          hosts: all
          become: true
          tasks:
          - name: Ansible create user example.
          user:
          name: vasanth
          password: vasanth


          Or it can be placed on individual tasks to run only those tasks with
          elevated privileges:



          hosts: all
          tasks:
          - name: Ansible create user example.
          become: true
          user:
          name: vasanth
          password: vasanth


          The become key isn't used exclusively for privilege escalation; it
          can be used to ask Ansible to run as any user in combination with the
          become_user key. You can read more in the docs.






          share|improve this answer
























          • i have added become: true and then the creation is success but i am not able to login with that user in the target machine. it says password incorrect. i have read many places over the web , they say i have to give the hashed key as password from playbook - is it true? if yes, is there a way i can create the hash programatically from the playbook(for a given plain text password) and then create the user?

            – Vasanth Nag K V
            Nov 13 '18 at 12:26











          • @VasanthNagKV the password needs to be crypted, ref. docs.ansible.com/ansible/… this is mentioned in the description of the modules password argument, ref. docs.ansible.com/ansible/2.5/modules/user_module.html

            – masseyb
            Nov 13 '18 at 19:33





















          2














          Two different problems here:



          1. Sort out your SSH keys



          Ansible is trying to connect using SSH keys and it fails:



          "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn"


          I'll suggest that you try first to ssh in your server: ssh admin@10.0.0.47



          This will probably fail, either because your public key is not in the authorized_keys of your server or because of key mappings in your ~/.ssh/config.



          Once you are able to ssh in the server, Ansible should be able too.



          2. Creating a user



          Take a look to the ansible output:



          ...
          "msg": "[Errno 13] Permission denied"


          Your user doesn't have enough privileges to create users. If your admin user belongs to the wheel group, you can use become to run the task as root:



          hosts: all
          tasks:
          - name: Ansible create user example.
          become: yes
          user:
          name: vasanth
          # ...





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280003%2fansible-playbook-execution-fails-for-user-creation-with-permission-issue%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            If you're not connecting to the remote host as root, then you need to tell Ansible to become root when running your tasks using the become: key, which can be placed on a play to run all tasks in that play with elevated privileges:



            hosts: all
            become: true
            tasks:
            - name: Ansible create user example.
            user:
            name: vasanth
            password: vasanth


            Or it can be placed on individual tasks to run only those tasks with
            elevated privileges:



            hosts: all
            tasks:
            - name: Ansible create user example.
            become: true
            user:
            name: vasanth
            password: vasanth


            The become key isn't used exclusively for privilege escalation; it
            can be used to ask Ansible to run as any user in combination with the
            become_user key. You can read more in the docs.






            share|improve this answer
























            • i have added become: true and then the creation is success but i am not able to login with that user in the target machine. it says password incorrect. i have read many places over the web , they say i have to give the hashed key as password from playbook - is it true? if yes, is there a way i can create the hash programatically from the playbook(for a given plain text password) and then create the user?

              – Vasanth Nag K V
              Nov 13 '18 at 12:26











            • @VasanthNagKV the password needs to be crypted, ref. docs.ansible.com/ansible/… this is mentioned in the description of the modules password argument, ref. docs.ansible.com/ansible/2.5/modules/user_module.html

              – masseyb
              Nov 13 '18 at 19:33


















            2














            If you're not connecting to the remote host as root, then you need to tell Ansible to become root when running your tasks using the become: key, which can be placed on a play to run all tasks in that play with elevated privileges:



            hosts: all
            become: true
            tasks:
            - name: Ansible create user example.
            user:
            name: vasanth
            password: vasanth


            Or it can be placed on individual tasks to run only those tasks with
            elevated privileges:



            hosts: all
            tasks:
            - name: Ansible create user example.
            become: true
            user:
            name: vasanth
            password: vasanth


            The become key isn't used exclusively for privilege escalation; it
            can be used to ask Ansible to run as any user in combination with the
            become_user key. You can read more in the docs.






            share|improve this answer
























            • i have added become: true and then the creation is success but i am not able to login with that user in the target machine. it says password incorrect. i have read many places over the web , they say i have to give the hashed key as password from playbook - is it true? if yes, is there a way i can create the hash programatically from the playbook(for a given plain text password) and then create the user?

              – Vasanth Nag K V
              Nov 13 '18 at 12:26











            • @VasanthNagKV the password needs to be crypted, ref. docs.ansible.com/ansible/… this is mentioned in the description of the modules password argument, ref. docs.ansible.com/ansible/2.5/modules/user_module.html

              – masseyb
              Nov 13 '18 at 19:33
















            2












            2








            2







            If you're not connecting to the remote host as root, then you need to tell Ansible to become root when running your tasks using the become: key, which can be placed on a play to run all tasks in that play with elevated privileges:



            hosts: all
            become: true
            tasks:
            - name: Ansible create user example.
            user:
            name: vasanth
            password: vasanth


            Or it can be placed on individual tasks to run only those tasks with
            elevated privileges:



            hosts: all
            tasks:
            - name: Ansible create user example.
            become: true
            user:
            name: vasanth
            password: vasanth


            The become key isn't used exclusively for privilege escalation; it
            can be used to ask Ansible to run as any user in combination with the
            become_user key. You can read more in the docs.






            share|improve this answer













            If you're not connecting to the remote host as root, then you need to tell Ansible to become root when running your tasks using the become: key, which can be placed on a play to run all tasks in that play with elevated privileges:



            hosts: all
            become: true
            tasks:
            - name: Ansible create user example.
            user:
            name: vasanth
            password: vasanth


            Or it can be placed on individual tasks to run only those tasks with
            elevated privileges:



            hosts: all
            tasks:
            - name: Ansible create user example.
            become: true
            user:
            name: vasanth
            password: vasanth


            The become key isn't used exclusively for privilege escalation; it
            can be used to ask Ansible to run as any user in combination with the
            become_user key. You can read more in the docs.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 13 '18 at 12:10









            larskslarsks

            114k19187195




            114k19187195













            • i have added become: true and then the creation is success but i am not able to login with that user in the target machine. it says password incorrect. i have read many places over the web , they say i have to give the hashed key as password from playbook - is it true? if yes, is there a way i can create the hash programatically from the playbook(for a given plain text password) and then create the user?

              – Vasanth Nag K V
              Nov 13 '18 at 12:26











            • @VasanthNagKV the password needs to be crypted, ref. docs.ansible.com/ansible/… this is mentioned in the description of the modules password argument, ref. docs.ansible.com/ansible/2.5/modules/user_module.html

              – masseyb
              Nov 13 '18 at 19:33





















            • i have added become: true and then the creation is success but i am not able to login with that user in the target machine. it says password incorrect. i have read many places over the web , they say i have to give the hashed key as password from playbook - is it true? if yes, is there a way i can create the hash programatically from the playbook(for a given plain text password) and then create the user?

              – Vasanth Nag K V
              Nov 13 '18 at 12:26











            • @VasanthNagKV the password needs to be crypted, ref. docs.ansible.com/ansible/… this is mentioned in the description of the modules password argument, ref. docs.ansible.com/ansible/2.5/modules/user_module.html

              – masseyb
              Nov 13 '18 at 19:33



















            i have added become: true and then the creation is success but i am not able to login with that user in the target machine. it says password incorrect. i have read many places over the web , they say i have to give the hashed key as password from playbook - is it true? if yes, is there a way i can create the hash programatically from the playbook(for a given plain text password) and then create the user?

            – Vasanth Nag K V
            Nov 13 '18 at 12:26





            i have added become: true and then the creation is success but i am not able to login with that user in the target machine. it says password incorrect. i have read many places over the web , they say i have to give the hashed key as password from playbook - is it true? if yes, is there a way i can create the hash programatically from the playbook(for a given plain text password) and then create the user?

            – Vasanth Nag K V
            Nov 13 '18 at 12:26













            @VasanthNagKV the password needs to be crypted, ref. docs.ansible.com/ansible/… this is mentioned in the description of the modules password argument, ref. docs.ansible.com/ansible/2.5/modules/user_module.html

            – masseyb
            Nov 13 '18 at 19:33







            @VasanthNagKV the password needs to be crypted, ref. docs.ansible.com/ansible/… this is mentioned in the description of the modules password argument, ref. docs.ansible.com/ansible/2.5/modules/user_module.html

            – masseyb
            Nov 13 '18 at 19:33















            2














            Two different problems here:



            1. Sort out your SSH keys



            Ansible is trying to connect using SSH keys and it fails:



            "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn"


            I'll suggest that you try first to ssh in your server: ssh admin@10.0.0.47



            This will probably fail, either because your public key is not in the authorized_keys of your server or because of key mappings in your ~/.ssh/config.



            Once you are able to ssh in the server, Ansible should be able too.



            2. Creating a user



            Take a look to the ansible output:



            ...
            "msg": "[Errno 13] Permission denied"


            Your user doesn't have enough privileges to create users. If your admin user belongs to the wheel group, you can use become to run the task as root:



            hosts: all
            tasks:
            - name: Ansible create user example.
            become: yes
            user:
            name: vasanth
            # ...





            share|improve this answer




























              2














              Two different problems here:



              1. Sort out your SSH keys



              Ansible is trying to connect using SSH keys and it fails:



              "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn"


              I'll suggest that you try first to ssh in your server: ssh admin@10.0.0.47



              This will probably fail, either because your public key is not in the authorized_keys of your server or because of key mappings in your ~/.ssh/config.



              Once you are able to ssh in the server, Ansible should be able too.



              2. Creating a user



              Take a look to the ansible output:



              ...
              "msg": "[Errno 13] Permission denied"


              Your user doesn't have enough privileges to create users. If your admin user belongs to the wheel group, you can use become to run the task as root:



              hosts: all
              tasks:
              - name: Ansible create user example.
              become: yes
              user:
              name: vasanth
              # ...





              share|improve this answer


























                2












                2








                2







                Two different problems here:



                1. Sort out your SSH keys



                Ansible is trying to connect using SSH keys and it fails:



                "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn"


                I'll suggest that you try first to ssh in your server: ssh admin@10.0.0.47



                This will probably fail, either because your public key is not in the authorized_keys of your server or because of key mappings in your ~/.ssh/config.



                Once you are able to ssh in the server, Ansible should be able too.



                2. Creating a user



                Take a look to the ansible output:



                ...
                "msg": "[Errno 13] Permission denied"


                Your user doesn't have enough privileges to create users. If your admin user belongs to the wheel group, you can use become to run the task as root:



                hosts: all
                tasks:
                - name: Ansible create user example.
                become: yes
                user:
                name: vasanth
                # ...





                share|improve this answer













                Two different problems here:



                1. Sort out your SSH keys



                Ansible is trying to connect using SSH keys and it fails:



                "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).rn"


                I'll suggest that you try first to ssh in your server: ssh admin@10.0.0.47



                This will probably fail, either because your public key is not in the authorized_keys of your server or because of key mappings in your ~/.ssh/config.



                Once you are able to ssh in the server, Ansible should be able too.



                2. Creating a user



                Take a look to the ansible output:



                ...
                "msg": "[Errno 13] Permission denied"


                Your user doesn't have enough privileges to create users. If your admin user belongs to the wheel group, you can use become to run the task as root:



                hosts: all
                tasks:
                - name: Ansible create user example.
                become: yes
                user:
                name: vasanth
                # ...






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 '18 at 12:16









                el.atomoel.atomo

                2,55412026




                2,55412026






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280003%2fansible-playbook-execution-fails-for-user-creation-with-permission-issue%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Bressuire

                    Vorschmack

                    Quarantine