updating playbook to use a role
This commit is contained in:
51
test.yml
51
test.yml
@@ -1,50 +1,5 @@
|
|||||||
---
|
---
|
||||||
- hosts: all
|
- hosts: all
|
||||||
tasks:
|
roles:
|
||||||
- name: Create default user
|
- role: shell
|
||||||
user:
|
tags: shell
|
||||||
name: "{{ default_user }}"
|
|
||||||
password: "{{ default_user_password | password_hash('sha512') }}"
|
|
||||||
groups: sudo
|
|
||||||
create_home: yes
|
|
||||||
shell: /bin/zsh
|
|
||||||
generate_ssh_key: yes
|
|
||||||
ssh_key_bits: 2048
|
|
||||||
ssh_key_file: .ssh/id_rsa
|
|
||||||
update_password: always
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Ensure sudo group has passwordless sudo privileges
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/sudoers
|
|
||||||
state: present
|
|
||||||
regexp: "^%sudo"
|
|
||||||
line: "%sudo ALL=(ALL) NOPASSWD:ALL"
|
|
||||||
validate: "/usr/sbin/visudo -cf %s"
|
|
||||||
|
|
||||||
- name: Upgrade apt packages
|
|
||||||
apt:
|
|
||||||
update_cache: yes
|
|
||||||
upgrade: full
|
|
||||||
|
|
||||||
- name: Install apt packages
|
|
||||||
apt:
|
|
||||||
name: "{{ packages_to_install }}"
|
|
||||||
|
|
||||||
- name: Get default user home
|
|
||||||
getent:
|
|
||||||
database: passwd
|
|
||||||
key: "{{ default_user }}"
|
|
||||||
split: ":"
|
|
||||||
|
|
||||||
- name: Set default user home
|
|
||||||
set_fact:
|
|
||||||
default_user_home: "{{ getent_passwd[default_user][4] }}"
|
|
||||||
|
|
||||||
- name: Install Rustup
|
|
||||||
shell: curl https://sh.rustup.rs -sSf | sh -s -- -y
|
|
||||||
args:
|
|
||||||
creates: "{{ default_user_home }}/.cargo/bin/rustup"
|
|
||||||
environment:
|
|
||||||
RUSTUP_HOME: "{{ default_user_home }}/.rustup"
|
|
||||||
CARGO_HOME: "{{ default_user_home }}/.cargo"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user