Create a new user.

24 views
Skip to first unread message

Lars von trier pung

unread,
Apr 18, 2016, 8:29:01 AM4/18/16
to Ansible Project
Hi!


Is there a way so to specify "last line" in tags from a list?. I want to create a new user by using adhocs command. So it won't have to go through all the userlist everytime. Only the last added line. In this case    - { id: '7' , user: 'user7' }


tasks - main.yml:

- name: Add vnc users
  user: name={{ item.user }} home={{ home_dir }}/{{ item.user }}
  with_items:
    - "{{ vnc_servers }}"
  tags: addnewuser





vars - main.yml:

---

service_name: vncserver

home_dir: "{{ opt_dir }}/home"
vnc_servers:
  - { id: '1' , user: 'user1' }
  - { id: '2' , user: 'user2' }
  - { id: '3' , user: 'user3' }
  - { id: '4' , user: 'user4' }
  - { id: '5' , user: 'user5' }
  - { id: '6' , user: 'user6' }
  - { id: '7' , user: 'user7' } = newly added user




Dejay Clayton

unread,
May 12, 2016, 4:44:22 PM5/12/16
to Ansible Project
On Monday, April 18, 2016 at 8:29:01 AM UTC-4, Lars von trier pung wrote:
Is there a way so to specify "last line" in tags from a list?

Have you tried using the "last" filter?

with_items:
    - "{{ vnc_servers | last }}" 
Reply all
Reply to author
Forward
0 new messages