Initial automated server provision via Ansible
This commit is contained in:
parent
e317b27972
commit
6d5d638a14
4 changed files with 124 additions and 0 deletions
16
ansible.cfg
16
ansible.cfg
|
|
@ -0,0 +1,16 @@
|
|||
[defaults]
|
||||
inventory = inventory.ini
|
||||
remote_user = stephen
|
||||
private_key_file = ~/.ssh/id_ed25519_ansible
|
||||
host_key_checking = False
|
||||
stdout_callback = ansible.builtin.default
|
||||
result_format = yaml
|
||||
|
||||
[privilege_escalation]
|
||||
become = True
|
||||
become_method = sudo
|
||||
become_user = root
|
||||
become_ask_pass = False
|
||||
|
||||
[ssh_connection]
|
||||
pipelining = True
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
# Domain & SSL Settings
|
||||
domain_name: dev.oxnee.com
|
||||
letsencrypt_email: stephen.lohning@oxnee.com
|
||||
|
||||
# Forgejo Settings
|
||||
forgejo_version: "9.0.2"
|
||||
forgejo_db_user: forgejo
|
||||
forgejo_db_name: forgejo
|
||||
# Note: Forgejo will prompt you for the DB password during the
|
||||
# first web login, so we don't strictly need to hardcode it here.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
[potato]
|
||||
192.168.1.210 ansible_user=stephen
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
- name: Provision Potato Server Infrastructure
|
||||
hosts: potato
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Install System Dependencies
|
||||
apt:
|
||||
name:
|
||||
- cockpit
|
||||
- nginx
|
||||
- certbot
|
||||
- python3-certbot-nginx
|
||||
- git
|
||||
state: present
|
||||
|
||||
# --- FORGEJO SYSTEM USER & DIRECTORIES ---
|
||||
- name: Create Git system user for Forgejo
|
||||
user:
|
||||
name: git
|
||||
home: /home/git
|
||||
shell: /bin/bash
|
||||
system: yes
|
||||
|
||||
- name: Create Forgejo application directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: git
|
||||
group: git
|
||||
mode: '0750'
|
||||
loop:
|
||||
- /var/lib/forgejo
|
||||
- /var/lib/forgejo/data
|
||||
- /var/lib/forgejo/custom
|
||||
- /var/lib/forgejo/log
|
||||
- /etc/forgejo
|
||||
|
||||
# --- FORGEJO BINARY INSTALLATION ---
|
||||
- name: Download Forgejo Linux AMD64 binary
|
||||
get_url:
|
||||
url: "https://codeberg.org/forgejo/forgejo/releases/download/v{{ forgejo_version }}/forgejo-{{ forgejo_version }}-linux-amd64"
|
||||
dest: /usr/local/bin/forgejo
|
||||
mode: '0755'
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Provision Forgejo Systemd Service Unit
|
||||
copy:
|
||||
dest: /etc/systemd/system/forgejo.service
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Forgejo (Git Service)
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
After=postgresql.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=git
|
||||
Group=git
|
||||
WorkingDirectory=/var/lib/forgejo/
|
||||
Environment=USER=git HOME=/home/git FORGEJO_WORK_DIR=/var/lib/forgejo
|
||||
ExecStart=/usr/local/bin/forgejo web --config /etc/forgejo/app.ini
|
||||
Restart=always
|
||||
RestartSec=2s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
# --- SERVICE MANAGEMENT ---
|
||||
- name: Enable and start system infrastructure services
|
||||
service:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: yes
|
||||
loop:
|
||||
- cockpit
|
||||
- nginx
|
||||
- forgejo
|
||||
# Install System Dependencies for Nginx and Certbot
|
||||
- name: Remove default Nginx site configuration
|
||||
file:
|
||||
path: /etc/nginx/sites-enabled/default
|
||||
state: absent
|
||||
|
||||
- name: Reload Nginx to apply changes
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
Loading…
Reference in a new issue