ansibletest/playbook.yaml

55 lines
1.2 KiB
YAML
Raw Permalink Normal View History

2023-03-18 22:52:37 +05:30
---
- name: Install shit
2023-03-18 00:06:52 +05:30
hosts: ansibletest
tasks:
2023-03-18 22:52:37 +05:30
- name: Std Repo stuff
apt:
update_cache: true
name:
- vim
- curl
- wget
- sudo
2023-04-19 21:23:19 +05:30
- net-tools
- nmap
2023-04-20 17:06:11 +05:30
- python3-pip
- python3-docker
2023-03-18 22:52:37 +05:30
- name: Add users
hosts: ansibletest
vars:
users:
- akis
- arya
- devrand
- midou
2023-03-18 23:06:39 +05:30
vars_prompt:
- name: password
prompt: What is password to be used for all accs?
encrypt: sha512_crypt
confirm: true
salt_size: 6
2023-03-18 22:52:37 +05:30
tasks:
- name: Add user
ansible.builtin.user:
name: "{{ item }}"
group: users
groups: users,sudo
2023-03-18 23:06:39 +05:30
password: "{{ password }}"
2023-03-18 22:52:37 +05:30
shell: /bin/bash
update_password: on_create
with_items:
- "{{ users }}"
- name: "Add authorized keys"
authorized_key:
user: "{{ item }}"
key: "{{ lookup('file', 'files/'+ item + '.pub') }}"
with_items:
- "{{ users }}"
- name: "Allow admin users to sudo without a password"
lineinfile:
dest: "/etc/sudoers" # path: in version 2.3
state: "present"
regexp: "^%sudo"
line: "%sudo ALL=(ALL) NOPASSWD: ALL"