Added code to create user
This commit is contained in:
parent
14473a683b
commit
ab2a108068
7 changed files with 82 additions and 0 deletions
5
ansible.cfg
Normal file
5
ansible.cfg
Normal file
|
@ -0,0 +1,5 @@
|
|||
[defaults]
|
||||
INVENTORY = hosts
|
||||
|
||||
[ssh_connections]
|
||||
pipelining = true
|
6
group_vars/all/vars.yml
Normal file
6
group_vars/all/vars.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
username: noble
|
||||
packages:
|
||||
- vim
|
||||
- htop
|
||||
- neofetch
|
||||
- tmux
|
2
hosts
Normal file
2
hosts
Normal file
|
@ -0,0 +1,2 @@
|
|||
[home]
|
||||
void ansible_host=192.168.1.193 ansible_user=ansible ansible_connection=ssh ansible_ssh_private_key_file=/home/noble/.ssh/ansible
|
11
run.yml
Normal file
11
run.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
- hosts: void
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- name: Print information
|
||||
debug:
|
||||
msg: "Release version: {{ ansible_distribution_release }}"
|
||||
|
||||
- import_tasks: tasks/base.yml
|
||||
- import_tasks: tasks/docker.yml
|
36
tasks/base.yml
Normal file
36
tasks/base.yml
Normal file
|
@ -0,0 +1,36 @@
|
|||
- name: Update packages
|
||||
apt:
|
||||
update_cache: yes
|
||||
upgrade: yes
|
||||
state: latest
|
||||
|
||||
- name: Install essential packages
|
||||
apt:
|
||||
pkg: "{{ packages }}"
|
||||
update_cache: yes
|
||||
state: latest
|
||||
|
||||
- name: Add the user "{{ username }}"
|
||||
user:
|
||||
name: "{{ username }}"
|
||||
shell: /bin/bash
|
||||
groups: sudo
|
||||
append: yes
|
||||
|
||||
- name: Set authorized ssh key for user "{{ username }}"
|
||||
authorized_key:
|
||||
user: "{{ username }}"
|
||||
state: present
|
||||
key: "{{ lookup('file', '/home/noble/.ssh/nexus-to-pi.pub') }}"
|
||||
|
||||
- name: Enable passwordless sudo for ansible
|
||||
lineinfile:
|
||||
path: /etc/sudoers
|
||||
state: present
|
||||
regexp: '^ansible'
|
||||
line: 'ansible ALL=(ALL) NOPASSWD:ALL'
|
||||
validate: /usr/sbin/visudo -cf %s
|
||||
|
||||
- name: Set hostname to void
|
||||
hostname:
|
||||
name: void
|
18
tasks/docker.yml
Normal file
18
tasks/docker.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
- name: Install dependencies
|
||||
package:
|
||||
name:
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg
|
||||
- lsb-release
|
||||
|
||||
- name: Add Docker GPG key
|
||||
apt_key:
|
||||
url: https://download.docker.com/linux/raspbian/gpg
|
||||
keyring: /usr/share/keyrings/docker-archive-keyring.gpg
|
||||
state: present
|
||||
|
||||
- name: Add Docker repository
|
||||
apt_repository:
|
||||
repo: https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable
|
||||
state: present
|
4
tasks/unattended-upgrades.yml
Normal file
4
tasks/unattended-upgrades.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- name: Install unattended-upgrades
|
||||
package:
|
||||
name:
|
||||
- unattended-upgrades
|
Loading…
Reference in a new issue