Skip to content

Instantly share code, notes, and snippets.

@tuannvm
Last active January 6, 2017 08:33
Show Gist options
  • Save tuannvm/2c0ee5fe5a2035e29e2a60b11d451e42 to your computer and use it in GitHub Desktop.
Save tuannvm/2c0ee5fe5a2035e29e2a60b11d451e42 to your computer and use it in GitHub Desktop.
"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