This commit is contained in:
Hubert Cornet 2024-04-01 10:40:20 +02:00
parent 5152f44924
commit 8a7c4f3724
154 changed files with 100 additions and 0 deletions

18
Installation/readme.md Normal file
View File

@ -0,0 +1,18 @@
# Update Repos
```
sudo apt update
```
# Install Dependencies
```
sudo apt install software-properties-common
```
# Add Ansible Repo
```
sudo add-apt-repository --yes --update ppa:ansible/ansible
```
# Install Ansible
```
sudo apt install ansible
```

View File

@ -0,0 +1,7 @@
# Add to Hosts File (change ansible_user if required)
```
[all:vars]
ansible_user='ubuntu'
ansible_become=yes
ansible_become_method=sudo
```

View File

@ -0,0 +1,24 @@
---
- hosts: all
gather_facts: yes
become: yes
tasks:
- name: Perform a distro upgrade
ansible.builtin.apt:
upgrade: dist
update_cache: yes
- name: Check if a reboot is required
ansible.builtin.stat:
path: /var/run/reboot-required
get_checksum: no
register: reboot_required_file
- name: Reboot the server (if necessary)
ansible.builtin.reboot:
when: reboot_required_file.stat.exists == true
- name: Remove dependencies that are no longer needed
ansible.builtin.apt:
autoremove: yes

View File

@ -0,0 +1,23 @@
---
- hosts: all
become: true
tasks:
- name: Update apt repo and cache on all Debian/Ubuntu boxes
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
- name: Upgrade all packages on servers
apt: upgrade=dist force_apt_get=yes
- name: Check if a reboot is needed on all servers
register: reboot_required_file
stat: path=/var/run/reboot-required get_checksum=false
- name: Reboot the box if kernel updated
reboot:
msg: "Reboot initiated by Ansible for kernel updates"
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists

28
SSH/readme.md Normal file
View File

@ -0,0 +1,28 @@
# Edit Hosts File
```
sudo nano /etc/ansible/hosts
```
# Fix SSH Key Permissions
```
chmod 600 ~/.ssh/ansible
```
# Ansible Ping Command
```
ansible all -m ping
```
# Create SSH Key
```
ssh-keygen -t ed25519 -C "ansible"
```
# Copy SSH Key
```
ssh-copy-id -i ~/.ssh/ansible.pub 192.168.200.50
```
# Ansible Ping Command With New SSH Key
```
ansible all -m ping --key-file ~/.ssh/ansible
```

Some files were not shown because too many files have changed in this diff Show More