Skip to content

Instantly share code, notes, and snippets.

@denisse-dev
Created January 26, 2020 03:30
Show Gist options
  • Save denisse-dev/bd3099cfc045aea62b55541d726f77d5 to your computer and use it in GitHub Desktop.
Save denisse-dev/bd3099cfc045aea62b55541d726f77d5 to your computer and use it in GitHub Desktop.
---
- name: Ensure a the user bouncie is created with sudo access
hosts: localhost
become: yes
tasks:
- name: Create the bouncie user
user:
name: bouncie
shell: /bin/bash
- name: Give sudo access to the bouncie user
lineinfile:
path: /etc/sudoers.d/bouncie
line: 'bouncie ALL=(ALL) ALL'
create: yes
- name: Ensure my public keys are added to the bouncie user
hosts: localhost
become: yes
tasks:
- name: Crete the SSH directory on bouncie's home folder
file:
path: /home/bouncie/.ssh/
state: directory
owner: bouncie
group: bouncie
mode: '0700'
- name: Import my public keys
get_url:
url: https://github.com/da-edra.keys
dest: /home/bouncie/.ssh/authorized_keys
owner: bouncie
group: bouncie
mode: '0600'
- name: Ensure the bouncie user will set up a password on first login
hosts: localhost
become: yes
tasks:
- name: Disable bouncie's password and expire it
shell:
cmd: passwd -d bouncie
- name: Expire bouncie's password
shell:
cmd: passwd -e bouncie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment