mirror of
https://github.com/CPunch/openpunk-ansible.git
synced 2024-11-22 07:20:05 +00:00
Added dead switch
This commit is contained in:
parent
e795959672
commit
201d17efaa
12
README.md
12
README.md
@ -1,18 +1,24 @@
|
|||||||
# OpenPunk's ansible recovery
|
# OpenPunk's Ansible playbook
|
||||||
|
|
||||||
This is my failsafe (and also my helpful migration tool) for restoring the OpenPunk server. This handles setting everything back up, including:
|
This is my failsafe (and also my helpful migration tool) for restoring the OpenPunk server. This handles setting everything back up, including:
|
||||||
|
|
||||||
- gitea
|
- gitea
|
||||||
- blog
|
- blog
|
||||||
- nginx
|
|
||||||
- tor mirror
|
- tor mirror
|
||||||
|
- nginx (for the above mentioned)
|
||||||
|
- my shell theme (zsh + powerlevel10k)
|
||||||
|
- deadswitch (& the ssh + git config to allow pushes)
|
||||||
|
|
||||||
|
## Notes to my future self
|
||||||
|
|
||||||
|
The deadswitch is disabled by default. Delete the file lock at `/root/.deadlock` to enable it.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
ansible-playbook -i hosts --ask-vault-pass run.yml
|
ansible-playbook -i hosts --ask-vault-pass run.yml
|
||||||
```
|
```
|
||||||
> NOTE: The 'secrets' directory has been omitted from the repo
|
> NOTE: The 'secrets' directory has been omitted from this repo (so it's not going to run without the provided files)
|
||||||
|
|
||||||
## Example hosts file
|
## Example hosts file
|
||||||
|
|
||||||
|
1
run.yml
1
run.yml
@ -15,4 +15,5 @@
|
|||||||
- import_tasks: tasks/blog-setup.yml
|
- import_tasks: tasks/blog-setup.yml
|
||||||
- import_tasks: tasks/gitea.yml
|
- import_tasks: tasks/gitea.yml
|
||||||
- import_tasks: tasks/tor.yml
|
- import_tasks: tasks/tor.yml
|
||||||
|
- import_tasks: tasks/deadswitch.yml
|
||||||
- import_tasks: tasks/nginx.yml
|
- import_tasks: tasks/nginx.yml
|
@ -1,15 +1,9 @@
|
|||||||
|
---
|
||||||
- name: Clone blog repository
|
- name: Clone blog repository
|
||||||
git:
|
git:
|
||||||
repo: "https://github.com/CPunch/openpunk.git"
|
repo: "https://github.com/CPunch/openpunk.git"
|
||||||
dest: "/var/www/{{ domain }}"
|
dest: "/var/www/{{ domain }}"
|
||||||
|
|
||||||
- name: Setup git config
|
|
||||||
copy:
|
|
||||||
src: templates/.gitconfig
|
|
||||||
dest: /root/.gitconfig
|
|
||||||
owner: root
|
|
||||||
mode: u=rw,g=,o=
|
|
||||||
|
|
||||||
- name: Build blog
|
- name: Build blog
|
||||||
command:
|
command:
|
||||||
cmd: hugo
|
cmd: hugo
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
- name: Create deadman directory
|
||||||
|
file:
|
||||||
|
name: /root/deadman
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Install deadswitch script
|
||||||
|
copy:
|
||||||
|
src: templates/blog/deadswitch
|
||||||
|
dest: /usr/local/bin/deadswitch
|
||||||
|
mode: u+rwx
|
||||||
|
|
||||||
|
- name: Install imdead.sh
|
||||||
|
copy:
|
||||||
|
src: templates/blog/imdead.sh
|
||||||
|
dest: /root/deadman/imdead.sh
|
||||||
|
mode: u+rwx
|
||||||
|
|
||||||
|
- name: Copy dead message
|
||||||
|
template:
|
||||||
|
src: secrets/dead.md
|
||||||
|
dest: /root/deadman/dead.md
|
||||||
|
|
||||||
|
- name: Install deadlock, disabling the deadswitch
|
||||||
|
file:
|
||||||
|
name: /root/.deadlock
|
||||||
|
state: touch
|
||||||
|
|
||||||
|
- name: Install deadlock cronjob
|
||||||
|
cron:
|
||||||
|
name: Run deadswitch
|
||||||
|
minute: 0
|
||||||
|
hour: 1
|
||||||
|
job: /usr/local/bin/deadswitch
|
@ -32,7 +32,12 @@
|
|||||||
shell: chsh -s /usr/bin/zsh
|
shell: chsh -s /usr/bin/zsh
|
||||||
|
|
||||||
- name: Clone Powerlevel10k theme
|
- name: Clone Powerlevel10k theme
|
||||||
shell: git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /root/powerlevel10k
|
git:
|
||||||
|
repo: "https://github.com/romkatv/powerlevel10k.git"
|
||||||
|
dest: "/root/powerlevel10k"
|
||||||
|
depth: 1
|
||||||
|
|
||||||
- name: Install Powerlevel10k theme
|
- name: Install .zshrc
|
||||||
shell: echo 'source /root/powerlevel10k/powerlevel10k.zsh-theme' > /root/.zshrc
|
copy:
|
||||||
|
src: templates/.zshrc
|
||||||
|
dest: /root/.zshrc
|
26
tasks/git.yml
Normal file
26
tasks/git.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
- name: Setup git config
|
||||||
|
copy:
|
||||||
|
src: templates/.gitconfig
|
||||||
|
dest: /root/.gitconfig
|
||||||
|
owner: root
|
||||||
|
mode: u=rw,g=,o=
|
||||||
|
|
||||||
|
- name: Scan for SSH host keys.
|
||||||
|
local_action:
|
||||||
|
module: shell
|
||||||
|
cmd: ssh-keyscan git.{{ domain }} 2>/dev/null
|
||||||
|
changed_when: False
|
||||||
|
register: ssh_scan
|
||||||
|
|
||||||
|
- name: Update known_hosts.
|
||||||
|
local_action:
|
||||||
|
module: known_hosts
|
||||||
|
key: "{{ item }}"
|
||||||
|
name: git.{{ domain }}
|
||||||
|
with_items: "{{ ssh_scan.stdout_lines }}"
|
||||||
|
|
||||||
|
- name: Install ssh keys
|
||||||
|
clone:
|
||||||
|
src: secrets/id_ed25519
|
||||||
|
dest: /root/.ssh/id_ed25519
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
- name: Configure Gitea
|
- name: Configure Gitea
|
||||||
template:
|
template:
|
||||||
src: templates/gitea/app.ini
|
src: templates/gitea/app.ini
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
- name: Remove default nginx config
|
- name: Remove default nginx config
|
||||||
file:
|
file:
|
||||||
name: /etc/nginx/sites-enabled
|
name: /etc/nginx/sites-enabled
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
- name: Install torrc
|
- name: Install torrc
|
||||||
template:
|
template:
|
||||||
src: templates/tor/torrc
|
src: templates/tor/torrc
|
||||||
|
1
templates/.zshrc
Normal file
1
templates/.zshrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
source /root/powerlevel10k/powerlevel10k.zsh-theme
|
@ -9,11 +9,11 @@ currDate=$(date '+%Y-%m-%d')
|
|||||||
git clone git@github.com:CPunch/openpunk.git
|
git clone git@github.com:CPunch/openpunk.git
|
||||||
cp $postTemplate $pageName
|
cp $postTemplate $pageName
|
||||||
|
|
||||||
# replace our {{DATE}} with the current date
|
# replace our --DATE-- with the current date
|
||||||
sed -i 's/{{DATE}}/'$currDate'/g' $pageName
|
sed -i 's/--DATE--/'$currDate'/g' $pageName
|
||||||
|
|
||||||
# commit & push the post
|
# commit & push the post
|
||||||
cd openpunk
|
cd openpunk
|
||||||
git add .
|
git add .
|
||||||
git commit -m "DeadSwitch: Posted dead message"
|
git commit -m "DeadSwitch: No response from CPunch in 14 days, posting dead.md"
|
||||||
git push
|
git push --force
|
||||||
|
Loading…
Reference in New Issue
Block a user