initial commit

This commit is contained in:
Josh Lay 2019-02-25 21:49:51 -06:00
commit 800836b2d9
23 changed files with 609 additions and 0 deletions

View file

@ -0,0 +1,23 @@
---
- name: creating user {{ username }} in sudo group (Debian/Ubuntu)
user:
name: "{{ username }}"
password: "{{ pwgen | password_hash('sha512') }}"
state: present
shell: /bin/bash
groups: sudo
append: yes
generate_ssh_key: yes
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa
update_password: on_create
register: user_created
- name: enable nopasswd sudo (Debian/Ubuntu)
lineinfile:
dest: /etc/sudoers
regexp: '^%sudo'
line: "%sudo ALL=(ALL:ALL) NOPASSWD:ALL"
state: present
validate: 'visudo -cf %s'

View file

@ -0,0 +1,23 @@
---
- name: creating user {{ username }} in wheel group (RHEL/CentOS/Fedora)
user:
name: "{{ username }}"
password: "{{ pwgen | password_hash('sha512') }}"
state: present
shell: /bin/bash
groups: wheel
append: yes
generate_ssh_key: yes
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa
update_password: on_create
register: user_created
- name: enable nopasswd sudo (RHEL/CentOS/Fedora)
lineinfile:
dest: /etc/sudoers
regexp: '^%wheel'
line: "%wheel ALL=(ALL) NOPASSWD: ALL"
state: present
validate: 'visudo -cf %s'

View file

@ -0,0 +1,20 @@
---
- include_tasks: deb.yml
when: ansible_distribution in ["Debian", "Ubuntu"]
- include_tasks: el.yml
when: ansible_distribution in ["CentOS", "Red Hat Enterprise Linux", "Fedora"]
- name: print generated password for {{ username }} on each host
debug: var=pwgen
when: user_created is changed
- name: copy current pubkeys to ~{{ username }}/.ssh/authorized_keys
authorized_key:
user: "{{ username }}"
state: present
key: "{{ item }}"
with_items:
- "{{ lookup('file','~/.ssh/id_ed25519.pub') }}"
- "{{ lookup('file','~/.ssh/id_rsa.pub') }}"