Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat users-v2.yaml
- - name: Add users from users dictionary
- #action: user name={{ item.key }} password={{ item.value.password }} shell={{ item.value.shell }} state={{ item.value.state }} remove=yes update_password=on_create groups="{{ item.key }},{{ item.value.group }}" append=no
- action: user name={{ item.key }} password={{ item.value.password }} shell={{ item.value.shell }} state={{ item.value.state }} remove=yes update_password=on_create groups="{{ item.value.group }}" append=yes
- with_dict: users
- ignore_errors: yes
- - name: Add keys from users dictionary
- action: authorized_key user={{ item.key }} key="{{ item.value.ssh_key }}" exclusive=yes
- with_dict: users
- ###########
- cat newuser-user.yaml
- - hosts: all
- # remote_user: ec2-user
- sudo: yes
- sudo_user: root
- vars_files:
- - newuser-users
- tasks:
- - copy: src=conf/custom-sudoers dest=/etc/sudoers.d/custom_sudoers owner=root group=root mode=644
- - group: name=default_group state=present
- - include: users-v2.yaml
- ##########
- cat newuser-users
- users:
- user1:
- password: MD5HASH
- shell: /bin/bash
- ssh_key: "{{ lookup('file', 'user1.pub') }}"
- state: present
- group: default_group
- user2:
- password: MD5HASH
- shell: /bin/bash
- ssh_key: "{{ lookup('file', 'user2.pub') }}"
- state: present
- group: default_group
- user3:
- password: MD5HASH
- shell: /bin/bash
- ssh_key: "{{ lookup('file', 'user3.pub') }}"
- state: present
- group: default_group
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement