Compare commits
5 Commits
master
...
fix/ansibl
Author | SHA1 | Date | |
---|---|---|---|
510baa7f94 | |||
088846cad9 | |||
1be3a8e588 | |||
da580eb7d2 | |||
a8d7c01efe |
playbooks
inventory.yamlmanual-prerequisites.yamlreadme.mdstatic-setup.yaml
static
files
handlers
tasks
templates
vars
runbooks
3
playbooks/inventory.yaml
Normal file
3
playbooks/inventory.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
static-web:
|
||||||
|
hosts:
|
||||||
|
shockrah.xyz:
|
9
playbooks/manual-prerequisites.yaml
Normal file
9
playbooks/manual-prerequisites.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: Pre Pipeline Playbook for Static Hosts
|
||||||
|
hosts: static-web
|
||||||
|
remote_user: root
|
||||||
|
tasks:
|
||||||
|
- name: Import manual setup steps
|
||||||
|
ansible.builtin.import_role:
|
||||||
|
name: static
|
||||||
|
tasks_from: setup-webadmin.yaml
|
5
playbooks/readme.md
Normal file
5
playbooks/readme.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# What is this
|
||||||
|
|
||||||
|
Here be the ansible based workflows that we use to keep things like the static
|
||||||
|
hosts properly setup with all the resources they need to properly host the
|
||||||
|
services we intended on hosting.
|
8
playbooks/static-setup.yaml
Normal file
8
playbooks/static-setup.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Static Host Maintenance and Setup
|
||||||
|
hosts: static-web
|
||||||
|
remote_user: webadmin
|
||||||
|
tasks:
|
||||||
|
- name: Import static host role
|
||||||
|
ansible.builtin.import_role:
|
||||||
|
name: static
|
0
playbooks/static/files/.gitkeep
Normal file
0
playbooks/static/files/.gitkeep
Normal file
0
playbooks/static/handlers/.gitkeep
Normal file
0
playbooks/static/handlers/.gitkeep
Normal file
5
playbooks/static/handlers/main.yaml
Normal file
5
playbooks/static/handlers/main.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
- name: Restart SSH
|
||||||
|
become: true
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: sshd
|
||||||
|
state: restarted
|
0
playbooks/static/tasks/.gitkeep
Normal file
0
playbooks/static/tasks/.gitkeep
Normal file
40
playbooks/static/tasks/main.yaml
Normal file
40
playbooks/static/tasks/main.yaml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Things that we definitely want to have are the following
|
||||||
|
# docker docker-compose python(latest) certbot
|
||||||
|
- name: Uhhh yea
|
||||||
|
become: true
|
||||||
|
block:
|
||||||
|
- name: Install base dependencies
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
pkg:
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- lsb-release
|
||||||
|
- name: Setup keyring directory
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "install -m 0755 -d {{ static_keyring_dir }}"
|
||||||
|
creates: "{{ static_keyring_dir }}"
|
||||||
|
- name: Download the docker GPG key
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ static_docker_ubuntu }}/gpg"
|
||||||
|
dest: "{{ static_keyring_dir }}/docker.asc"
|
||||||
|
mode: "0644"
|
||||||
|
- name: Ensure docker.lst is present
|
||||||
|
vars:
|
||||||
|
key_path: "{{ static_keyring_dir }}/docker.asc"
|
||||||
|
repo: "{{ static_docker_ubuntu }}"
|
||||||
|
os_codename: jammy
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: docker.list
|
||||||
|
dest: "{{ static_apt_sources_dir }}/docker.list"
|
||||||
|
mode: "0644"
|
||||||
|
- name: Install docker and python packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
pkg:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
- docker-buildx-plugin
|
||||||
|
- docker-compose-plugin
|
||||||
|
- python3
|
43
playbooks/static/tasks/setup-webadmin.yaml
Normal file
43
playbooks/static/tasks/setup-webadmin.yaml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
- name: Ensure sudo is available
|
||||||
|
ansible.builtin.apt:
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
pkg:
|
||||||
|
- sudo
|
||||||
|
- zsh
|
||||||
|
- name: Create webadmin user
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: webadmin
|
||||||
|
state: present
|
||||||
|
shell: /bin/zsh
|
||||||
|
groups:
|
||||||
|
- nginx
|
||||||
|
append: true
|
||||||
|
- name: Copy webadmin public key
|
||||||
|
ansible.posix.authorized_key:
|
||||||
|
user: webadmin
|
||||||
|
state: present
|
||||||
|
key: "{{ lookup('file', 'files/webadmin.pem.pub') }}"
|
||||||
|
- name: Add webadmin to sudoers
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "/etc/sudoers.d/webadmin"
|
||||||
|
content: "webadmin ALL=(ALL) NOPASSWD: ALL"
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
- name: Disable Password Authentication
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
dest: /etc/ssh/sshd_config
|
||||||
|
line: PasswordAuthentication no
|
||||||
|
state: present
|
||||||
|
backup: true
|
||||||
|
notify:
|
||||||
|
- Restart SSH
|
||||||
|
- name: Disable root login
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
dest: /etc/ssh/sshd_config
|
||||||
|
line: PermitRootLogin no
|
||||||
|
state: present
|
||||||
|
backup: true
|
||||||
|
notify:
|
||||||
|
- Restart SSH
|
0
playbooks/static/templates/.gitkeep
Normal file
0
playbooks/static/templates/.gitkeep
Normal file
1
playbooks/static/templates/docker.list
Normal file
1
playbooks/static/templates/docker.list
Normal file
@ -0,0 +1 @@
|
|||||||
|
deb [arch=amd64 signed-by={{ key_path }}] {{ repo }} {{ os_codename }} stable
|
0
playbooks/static/vars/.gitkeep
Normal file
0
playbooks/static/vars/.gitkeep
Normal file
4
playbooks/static/vars/main.yaml
Normal file
4
playbooks/static/vars/main.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
static_keyring_dir: /etc/apt/keyrings
|
||||||
|
static_docker_ubuntu: https://download.docker.com/linux/ubuntu
|
||||||
|
static_apt_sources_dir: /etc/apt/sources.list.d
|
||||||
|
static_codename: jammy
|
@ -1,45 +0,0 @@
|
|||||||
# What this covers
|
|
||||||
|
|
||||||
The creation of Atlas as it happened in order
|
|
||||||
|
|
||||||
## Commands Ran
|
|
||||||
|
|
||||||
Once the infra was provisioned and verified to be configured by Terraform correctly
|
|
||||||
we move on to the following
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Setup the machine to run docker
|
|
||||||
ansible-playbook -i hosts.ini atlas/init/system-deps.yml
|
|
||||||
|
|
||||||
# Second we copy over the contents of Alpha's mounted docker volumes
|
|
||||||
ansible-playbook -i hosts.ini atlas/init/perma-mount-drives.yml
|
|
||||||
|
|
||||||
# Next we copy over the data that we want to migrate ( if any )
|
|
||||||
ansible-playbook -i hosts.ini -e filebrowser=/path -e clippable=/path atlas/init/migrate-clips-files.yml
|
|
||||||
|
|
||||||
# Setup the services on the host that we want to run
|
|
||||||
ansible-playbook -i hosts.ini atlas/init/setup-containers.yml
|
|
||||||
|
|
||||||
# Next we put up the reverse proxy (nginx)
|
|
||||||
ansible-playbook -i hosts.ini atlas/init/setup-reverse-proxy.yml
|
|
||||||
|
|
||||||
# Finally we add TLS on top of nginx and we're done
|
|
||||||
ansible-playbook -i hosts.ini atlas/init/setup-certbot.yml
|
|
||||||
```
|
|
||||||
|
|
||||||
Maintenance should be straight forward for this machine as TLS is automatically
|
|
||||||
renewed every 3 months by a cron job. We can manually update the certs however
|
|
||||||
if we really want to. They also don't require anymore manual variable injection
|
|
||||||
like Alpha did as the only thing protected was `dev@shockrah.xyz` which is at
|
|
||||||
this point becoming semi-public. This means while it is associated with code
|
|
||||||
it is more of a _business e-mail_ so it can be placed in this repository with
|
|
||||||
very little concern.
|
|
||||||
|
|
||||||
System updates are now also to be fetched with a:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
ansible-playbook -i hosts.ini atlas/maintain/analyze-system-deps.yml
|
|
||||||
```
|
|
||||||
|
|
||||||
Which performs purely read operations and does not affect the state of the
|
|
||||||
machine.
|
|
@ -1,33 +0,0 @@
|
|||||||
# Mounting an attached drive
|
|
||||||
|
|
||||||
Assumptions:
|
|
||||||
|
|
||||||
* New drive is attached(in AWS) and detected in software
|
|
||||||
Ideally attachment is made through terraform
|
|
||||||
|
|
||||||
## Mounting Instructions (Step-by-Step)
|
|
||||||
|
|
||||||
1. Verify data does not have data: `sudo file -s /dev/xvdf`
|
|
||||||
|
|
||||||
Should return `data` if its ok. Other wise we're probably looking at the wrong
|
|
||||||
drive.
|
|
||||||
|
|
||||||
2. Create the filesystem on the new empty drive: `sudo mkfs -t ext4 /dev/xvdf`
|
|
||||||
|
|
||||||
3. Create mountpoint other wares to actaully use the drive
|
|
||||||
`sudo mkdir /mnt/example`.
|
|
||||||
|
|
||||||
Change _example_ to something that actually makes sense.
|
|
||||||
|
|
||||||
4. Add a new entry to /etc/fstab for automounting
|
|
||||||
|
|
||||||
`/dev/xvdf /newvolume ext4 defaults,nofail 0 0`
|
|
||||||
|
|
||||||
Tab delimited btw.
|
|
||||||
|
|
||||||
5. Mount all drives listed in `/etc/fstab` from before. `sudo mount -a`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user