Forgot to add! Playbook: # #About: This will create-user # --- - hosts: node1 become: yes roles: - create-user
Role: --- - name: Adding new user user: name=keith shell=/bin/bash append=yes generate_ssh_key=yes ssh_key_file=.ssh/id_rsa tags: - create-user - name: Adding user to sudoers lineinfile: dest=/etc/sudoers state=present regexp='^%{{user_name}}' line='%{{user_name}} ALL=(ALL) NOPASSWD:ALL' validate='visudo -cf %s' tags: - create-user-sudo - name: Adding public key to authorized_keys file: src=/home/{{user_name}}/.ssh/id_rsa.pub dest=/home/{{user_name}}/.ssh/authorized_keys state=link tags: - create-user-authorized-keys - name: Get the private key shell: cat /home/{{user_name}}/.ssh/id_rsa register: ssh_key tags: - create-user-display-keys - debug: var=ssh_key tags: - create-user-display-keys On Monday, January 30, 2023 at 9:44:00 AM UTC-6 walte...@nist.gov wrote: > We would need to see the playbook and role included. > > Walter > -- > Walter Rowe, Division Chief > Infrastructure Services, OISM > Mobile: 202.355.4123 <(202)%20355-4123> > > On Jan 30, 2023, at 10:40 AM, Keith Mills <mills....@gmail.com> wrote: > > Hello All, > > I need help with and undefined variable in my Ansible Role! Any help will > be appreciated! > > Ansible Version > ansible 2.9.27 > config file = /home/kjames/ansible.cfg > configured module search path = > [u'/home/kjames/.ansible/plugins/modules', > u'/usr/share/ansible/plugins/modules'] > ansible python module location = /usr/lib/python2.7/site-packages/ansible > executable location = /usr/bin/ansible > python version = 2.7.5 (default, Jun 28 2022, 15:30:04) [GCC 4.8.5 > 20150623 (Red Hat 4.8.5-44)] > > Configuration > ansible-config dump --only-changed > DEFAULT_BECOME(/home/kjames/Ansible/ansible.cfg) = True > DEFAULT_BECOME_ASK_PASS(/home/kjames/Ansible/ansible.cfg) = False > DEFAULT_BECOME_METHOD(/home/kjames/Ansible/ansible.cfg) = sudo > DEFAULT_BECOME_USER(/home/kjames/Ansible/ansible.cfg) = root > DEFAULT_HOST_LIST(/home/kjames/Ansible/ansible.cfg) = > [u'/home/kjames/Ansible/static-ini-inventory'] > DEFAULT_REMOTE_USER(/home/kjames/Ansible/ansible.cfg) = kjames > > OS / Environment > CentOS Linux release 7.9.2009 (Core) > > $ ansible-playbook ansible-playbooks/create-user.yml > > PLAY [node1] > ********************************************************************************************************************************* > > TASK [Gathering Facts] > *********************************************************************************************************************** > ok: [node1] > > TASK [create-user : Adding new user] > ********************************************************************************************************* > ok: [node1] > > TASK [create-user : Adding user to sudoers] > ************************************************************************************************** > fatal: [node1]: FAILED! => {"msg": "The task includes an option with an > undefined variable. *The error was: 'user_name' is undefined\n\nThe error > appears to be in > '/home/kjames/Ansible/ansible-playbooks/roles/create-user/tasks/main.yml': > line 7*, column 3, but may\nbe elsewhere in the file depending on the > exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: > Adding user to sudoers\n ^ here\n"} > > PLAY RECAP > *********************************************************************************************************************************** > node1 : ok=2 changed=0 unreachable=0 > failed=1 skipped=0 rescued=0 ignored=0 > > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/43ed5b64-1ca7-469b-9154-3e7104af32c2n%40googlegroups.com > > <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F43ed5b64-1ca7-469b-9154-3e7104af32c2n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C3251d186e94e4b899bae08db02d864e9%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638106900665193095%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=n0i3bmptqDZ4KyoO7N5tZMjQ2oZojnLu1x%2FQY6H5tF4%3D&reserved=0> > . > > > -- 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-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f66a9929-9f83-4a5f-b1c7-d7831e629fban%40googlegroups.com.