Last active
January 6, 2017 08:33
-
-
Save tuannvm/2c0ee5fe5a2035e29e2a60b11d451e42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"finn.yml" | |
################ | |
--- | |
- hosts: web | |
vars: | |
user: "finn" | |
public_key: "{{ lookup('file', 'finn.pub') }}" | |
deleted_user: "chip" | |
deleted_public_key: "{{ lookup('file', 'chip.pub') }}" | |
tasks: | |
-name: create specific user | |
user: | |
name: "{{ user }}" | |
comment: "John Doe" | |
- name: grant access to specific user | |
authorized_key: | |
user: "{{ user }}" | |
state: present | |
key: "{{ public_key }}" | |
- name: remove access to specific user | |
authorized_key: | |
user: "{{ deleted_user }}" | |
state: present | |
key: "{{ deleted_public_key }}" | |
################# | |
"hosts" | |
################## | |
[web] | |
server1 | |
server2 | |
server3 | |
################## | |
### save finn.pub to current folder ### | |
### RUN ### | |
ansible-playbook finn.yml -i hosts | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment