Compare commits
5 Commits
21d3dbbf28
...
94e6d890a8
Author | SHA1 | Date | |
---|---|---|---|
94e6d890a8 | |||
10343d8f36 | |||
9088458b5d | |||
f7966b041e | |||
1a58fcbb75 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
**/*venv
|
**/*venv
|
||||||
|
*.log
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Update the system
|
- name: Update the system
|
||||||
hosts: pibox
|
|
||||||
become: true
|
become: true
|
||||||
|
hosts: pibox
|
||||||
roles:
|
roles:
|
||||||
- role: apt-update-system
|
- role: apt-update-system
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Install Packages
|
- name: Remove Packages
|
||||||
become: true
|
become: true
|
||||||
hosts: pibox
|
hosts: pibox
|
||||||
tasks:
|
tasks:
|
||||||
- name: Loop over packages_to_install and install them
|
- name: Loop over packages_to_install and install them
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: apt-install-package
|
name: apt-install-package
|
||||||
loop: packages_to_install
|
loop: "{{ packages_to_install }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: package
|
loop_var: package
|
||||||
|
|
||||||
|
14
ansible/02-remove-packages.yml
Normal file
14
ansible/02-remove-packages.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install Packages
|
||||||
|
become: true
|
||||||
|
hosts: pibox
|
||||||
|
tasks:
|
||||||
|
- name: Loop over packages_to_remove and remove them
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: apt-remove-package
|
||||||
|
loop: "{{ packages_to_remove }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: package
|
||||||
|
|
||||||
|
...
|
14
ansible/play.sh
Executable file
14
ansible/play.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
playbook_name=$1
|
||||||
|
inventory_path="./inventories/"
|
||||||
|
log_path="../logs"
|
||||||
|
log_file="${log_path}/${playbook_name}.log"
|
||||||
|
|
||||||
|
mkdir -p "${log_path}"
|
||||||
|
|
||||||
|
echo "${playbook_name} started at $(date)" | tee -a "${log_file}"
|
||||||
|
|
||||||
|
{ time ansible-playbook -i "${inventory_path}" "${playbook_name}" ; } 2>&1 | tee -a "${log_file}"
|
||||||
|
|
||||||
|
echo "${playbook_name} finished at $(date)" | tee -a "${log_file}"
|
@ -5,6 +5,6 @@
|
|||||||
update_cache: true
|
update_cache: true
|
||||||
name: "{{ package }}"
|
name: "{{ package }}"
|
||||||
state: latest
|
state: latest
|
||||||
failed_when: package is unset
|
failed_when: package is undefined
|
||||||
|
|
||||||
...
|
...
|
||||||
|
10
ansible/roles/apt-remove-package/tasks/main.yml
Normal file
10
ansible/roles/apt-remove-package/tasks/main.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: "Remove {{ package }}"
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
name: "{{ package }}"
|
||||||
|
state: absent
|
||||||
|
failed_when: package is undefined
|
||||||
|
|
||||||
|
...
|
@ -14,6 +14,9 @@
|
|||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
autoclean: true
|
autoclean: true
|
||||||
autoremove: true
|
autoremove: true
|
||||||
|
|
||||||
|
- name: purge any left over files
|
||||||
|
ansible.builtin.apt:
|
||||||
purge: true
|
purge: true
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -24,6 +24,13 @@ Some ansible playbooks to manage a [pibox](https://pibox.io) in various ways
|
|||||||
- If you can't resolve any hosts, check DNS. It's always DNS.
|
- If you can't resolve any hosts, check DNS. It's always DNS.
|
||||||
1. Proceed to running playbooks
|
1. Proceed to running playbooks
|
||||||
|
|
||||||
|
## Running Playbooks
|
||||||
|
|
||||||
|
It's recommended to use [`play.sh`](./ansible/play.sh) as it will automatically create log files for the playbooks that you execute.
|
||||||
|
|
||||||
|
Its usage is: `./play.sh <playbook-name>`
|
||||||
|
|
||||||
|
|
||||||
## Fixing no SSH on latest version
|
## Fixing no SSH on latest version
|
||||||
|
|
||||||
During install of the custom image, `pi flasher` allowed me to configure things like the hostname, ssid, my ssh key, my user account. This sets up a script that runs when the pi reboots for the first time after install.
|
During install of the custom image, `pi flasher` allowed me to configure things like the hostname, ssid, my ssh key, my user account. This sets up a script that runs when the pi reboots for the first time after install.
|
||||||
|
Loading…
Reference in New Issue
Block a user