Linting + bootstrap Ansible user

This commit is contained in:
2026-03-01 20:14:00 +01:00
parent c071ef1995
commit df8eb83dc0
7 changed files with 26 additions and 8 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,3 @@
id_ansible_lab* id_ansible_lab
*.sw* *.sw*
inventory/prod/*.y*ml inventory/prod/*.y*ml

View File

@@ -0,0 +1,14 @@
#!/bin/env bash
PUBKEY=./id_ansible.pub
useradd ansible --create-home --shell /bin/bash
# Ensure existing but unusable password (for Ubuntu)
usermod -p '*' ansible
mkdir /home/ansible/.ssh
chown -R ansible:ansible /home/ansible/.ssh
install -m 600 $PUBKEY /home/ansible/.ssh/authorized_keys
chmod 700 /home/ansible/.ssh
# Allow passwordless sudo
echo "ansible ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/ansible

View File

@@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINRKrmDyGyAKcFGHWakIcbG9C2bLW+XaNdrD4ws6d+lw nicolo@Sidereus

View File

@@ -1,17 +1,18 @@
---
all: all:
vars: vars:
ansible_user: nicolo ansible_user: nicolo
ansible_ssh_private_key_file: ~/.ssh/id_ansible_lab ansible_ssh_private_key_file: ~/.ssh/id_ansible_lab
children: children:
debian: aton:
hosts: hosts:
debi13: debi13:
ansible_host: 127.0.0.1 ansible_host: 127.0.0.1
ansible_port: 2224 ansible_port: 2224
ubuntu:
hosts:
ubu24: ubu24:
ansible_host: 127.0.0.1 ansible_host: 127.0.0.1
ansible_port: 2223 ansible_port: 2223
alma9:
ansible_host: 127.0.0.1
ansible_port: 2222

View File

@@ -1,5 +1,7 @@
---
- name: Configure webserver with nginx - name: Configure webserver with nginx
hosts: debian hosts:
- aton
become: true become: true
roles: roles:

View File

@@ -1,5 +1,5 @@
---
- name: Restart nginx - name: Restart nginx
ansible.builtin.service: ansible.builtin.service:
name: nginx name: nginx
state: restarted state: restarted

View File

@@ -1,3 +1,4 @@
---
- name: Ensure nginx is installed - name: Ensure nginx is installed
ansible.builtin.package: ansible.builtin.package:
name: nginx name: nginx
@@ -12,4 +13,3 @@
group: root group: root
mode: '0644' mode: '0644'
notify: Restart nginx notify: Restart nginx