Linting + bootstrap Ansible user
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
id_ansible_lab*
|
id_ansible_lab
|
||||||
*.sw*
|
*.sw*
|
||||||
inventory/prod/*.y*ml
|
inventory/prod/*.y*ml
|
||||||
|
|||||||
14
bootstrap/create_ansible_user.sh
Executable file
14
bootstrap/create_ansible_user.sh
Executable 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
|
||||||
|
|
||||||
1
bootstrap/id_ansible_lab.pub
Normal file
1
bootstrap/id_ansible_lab.pub
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINRKrmDyGyAKcFGHWakIcbG9C2bLW+XaNdrD4ws6d+lw nicolo@Sidereus
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
---
|
||||||
- name: Configure webserver with nginx
|
- name: Configure webserver with nginx
|
||||||
hosts: debian
|
hosts:
|
||||||
|
- aton
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
---
|
||||||
- name: Restart nginx
|
- name: Restart nginx
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: nginx
|
name: nginx
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user