FIX: default user is ansible now. root is specified manually when needed
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Basic Proxmox guest deployment
|
- name: Basic Proxmox guest deployment
|
||||||
hosts: all
|
hosts: all
|
||||||
remote_user: root
|
remote_user: ansible
|
||||||
roles:
|
roles:
|
||||||
- ../roles/0_basic_postinstall
|
- ../roles/0_basic_postinstall
|
||||||
vars_files:
|
vars_files:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Configure ssh-server daemon
|
- name: Configure ssh-server daemon
|
||||||
|
remote_user: root
|
||||||
copy:
|
copy:
|
||||||
src: ../files/hardened_sshd.conf
|
src: ../files/hardened_sshd.conf
|
||||||
dest: /etc/ssh/sshd_config.d/hardened_sshd.conf
|
dest: /etc/ssh/sshd_config.d/hardened_sshd.conf
|
||||||
|
|||||||
@@ -14,16 +14,13 @@
|
|||||||
- unattended-upgrades
|
- unattended-upgrades
|
||||||
update-cache: yes # Run apt update before installation
|
update-cache: yes # Run apt update before installation
|
||||||
become: yes
|
become: yes
|
||||||
remote_user: ansible
|
|
||||||
|
|
||||||
|
|
||||||
# The same commands for Alpine
|
# The same commands for Alpine
|
||||||
- name: Update Alpine packages
|
- name: Update Alpine packages
|
||||||
when: (ansible_facts['distribution'] == "Alpine")
|
when: (ansible_facts['distribution'] == "Alpine")
|
||||||
command: /sbin/apk update
|
command: /sbin/apk update
|
||||||
remote_user: ansible
|
|
||||||
|
|
||||||
- name: Install the packages on Alpine
|
- name: Install the packages on Alpine
|
||||||
when: (ansible_facts['distribution'] == "Alpine")
|
when: (ansible_facts['distribution'] == "Alpine")
|
||||||
command: /sbin/apk add vim ranger zsh rsync git curl kitty
|
command: /sbin/apk add vim ranger zsh rsync git curl kitty
|
||||||
remote_user: ansible
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
## Installing packages
|
## Installing packages
|
||||||
- name: Install sudo on apt systems
|
- name: Install sudo on apt systems
|
||||||
|
remote_user: root
|
||||||
when: (ansible_facts['distribution'] == "Debian") or
|
when: (ansible_facts['distribution'] == "Debian") or
|
||||||
(ansible_facts['distribution'] == "Ubuntu")
|
(ansible_facts['distribution'] == "Ubuntu")
|
||||||
apt:
|
apt:
|
||||||
@@ -9,10 +10,12 @@
|
|||||||
update-cache: yes
|
update-cache: yes
|
||||||
|
|
||||||
- name: Update Alpine packages
|
- name: Update Alpine packages
|
||||||
|
remote_user: root
|
||||||
when: (ansible_facts['distribution'] == "Alpine")
|
when: (ansible_facts['distribution'] == "Alpine")
|
||||||
command: /sbin/apk update
|
command: /sbin/apk update
|
||||||
|
|
||||||
- name: Install sudo package on Alpine
|
- name: Install sudo package on Alpine
|
||||||
|
remote_user: root
|
||||||
when: (ansible_facts['distribution'] == "Alpine")
|
when: (ansible_facts['distribution'] == "Alpine")
|
||||||
command: /sbin/apk add sudo
|
command: /sbin/apk add sudo
|
||||||
|
|
||||||
@@ -20,12 +23,14 @@
|
|||||||
## Creating and setting up the ansible user
|
## Creating and setting up the ansible user
|
||||||
## First, create sshusers group to grant ssh access
|
## First, create sshusers group to grant ssh access
|
||||||
- name: Ensure group "sshusers" exists
|
- name: Ensure group "sshusers" exists
|
||||||
|
remote_user: root
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: sshusers
|
name: sshusers
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
## Add the user to sshusers (for ssh access) and sudo (gain root access)
|
## Add the user to sshusers (for ssh access) and sudo (gain root access)
|
||||||
- name: Create a new user with a password for Ansible
|
- name: Create a new user with a password for Ansible
|
||||||
|
remote_user: root
|
||||||
user:
|
user:
|
||||||
name: ansible
|
name: ansible
|
||||||
password: "{{ ansible_user_passwd_hash }}"
|
password: "{{ ansible_user_passwd_hash }}"
|
||||||
@@ -35,6 +40,7 @@
|
|||||||
|
|
||||||
## Since password authentication in SSH will be disabled, we need to add an authorized key
|
## Since password authentication in SSH will be disabled, we need to add an authorized key
|
||||||
- name: Set authorized key taken from file
|
- name: Set authorized key taken from file
|
||||||
|
remote_user: root
|
||||||
ansible.posix.authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: ansible
|
user: ansible
|
||||||
state: present
|
state: present
|
||||||
|
|||||||
Reference in New Issue
Block a user