daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Feb 4th, 2016 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. id,username,password,sudo
  2. 1,ansible1,ansible@123,yes
  3. 2,ansible2,ansible@123,no
  4. 3,ansible3,ansible@123,yes
  5. 4,ansible4,ansible@123,yes
  6.    
  7. ---
  8. ## executed but until loop failed; check
  9. - hosts: 192.168.0.3
  10.   vars:
  11.     count: "{{COUNT}}"
  12.     x: "1"
  13.     uname: "{{ lookup('csvfile', '{{x}} file=userlist.csv delimiter=, col=1') }}"
  14.     password: "{{ lookup('csvfile', '{{x}} file=userlist.csv delimiter=, col=2') }}"
  15.     sudo: "{{ lookup('csvfile', '{{x}} file=userlist.csv delimiter=, col=3') }}"
  16.  
  17.   tasks:
  18.     name: "user add"
  19.     action:
  20.      - user:
  21.          x: "x+=1"
  22.          name: "{{ uname }}"
  23.          password: "{{ password }}"
  24.          state: present
  25.     register: x
  26.     until: "{{x > count}}"
  27.  
  28.     name: "add to sudoers"
  29.     when: sudo == "yes"
  30.     lineinfile:
  31.       dest: /etc/sudoers
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top