I am passing an extra-vars that is not working into a role.

33 views
Skip to first unread message

Grim76

unread,
Feb 4, 2016, 12:37:17 PM2/4/16
to Ansible Project
I have a role that I am calling for simple user administration. I appreciate any feedback on what I am doing.

First of all here is the command line that I am running:

ansible-playbook -i inventories/rd general_users.yml --extra-vars "target=haproxy targetusers=bastionusers" -u <redacted> -K

The playbook will start fine and collects host data and properly pulls in my users.yml. Then when the actual user addition task fires off I get the following error:

fatal: [server1]: FAILED! => {"failed": true, "msg": "ERROR! 'unicode object' has no attribute 'comment'"}
fatal: [server2]: FAILED! => {"failed": true, "msg": "ERROR! 'unicode object' has no attribute 'comment'"}


general_users.yml
---
- hosts: '{{ target }}'

  become: yes
  tasks:
  roles:
    - { role: user_management, sudogroup: 'sudo', when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian" }
    - { role: user_management, sudogroup: 'wheel', when: ansible_distribution == "CentOS" or ansible_distribution == "Amazon" }

Role: user_management

tasks: main.yml
---
- include: users.yml

tasks: users.yml
---
- name: Adding users to bastion server.
  user: name="{{ item.username }}" comment="{{ item.comment }}" uid="{{ item.userid }}" password="{{ item.password }}" shell='/bin/bash' update_password="{{ item.updatepassword }}"
  with_items:
    - "{{ targetusers }}"

- name: Adding users public keys for users.
  authorized_key: user="{{ item.username }}" key="{{ lookup('file', 'keys/{{ item.username }}.pub') }}"
  with_items:
    - "{{ targetusers }}"

vars: main.yml

bastionusers:
  - { username: jblow, comment: Joe Blow, userid: 12000, password: $6$KTjoXb2b8u4fbctM$FPuJyXaRUiFeQq8lxGp/3pxC.YYvtK/7uXGgxvMHc/DWbRPbtpYpI4pgwaXXfXt8Im2FJ09wndLCKFO8I0bTZ0, updatepassword: on_create }


I am not sure what I am doing wrong here, but this is not working. I am probably missing something extremely simple, but have been at it too long to see it.

Thanks

Grim76

Reply all
Reply to author
Forward
0 new messages