Compare commits

...

38 Commits

Author SHA1 Message Date
Gleb Koval 72a790c038
don't suffocate the vm
Infrastructure / Check and run Ansbile playbooks (pull_request) Successful in 6m34s Details
2023-09-11 01:40:29 +01:00
Gleb Koval dfcfe941cf
actually fix order of things
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 11m8s Details
2023-09-11 01:27:02 +01:00
Gleb Koval ac3494efc5
fix order of tasks
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 5m55s Details
2023-09-11 01:19:31 +01:00
Gleb Koval 6b2a820282
increase apt timeout
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 7m58s Details
2023-09-11 01:05:55 +01:00
Gleb Koval 6dfab582c4
wait for 3 min afterall
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 7m28s Details
2023-09-11 00:49:27 +01:00
Gleb Koval 41a0c9393e
escalate to root for 0001
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 4m38s Details
2023-09-11 00:43:36 +01:00
Gleb Koval 92fbca47db
fix wait for conn
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 7m22s Details
2023-09-11 00:34:59 +01:00
Gleb Koval 5b0bae4865
maybe fix wait for conn
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 6m10s Details
2023-09-11 00:23:37 +01:00
Gleb Koval bc59bd5fdb
wut
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 6m23s Details
2023-09-11 00:16:16 +01:00
Gleb Koval 8b128060e3
improve playbooks
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 5m32s Details
2023-09-11 00:07:56 +01:00
Gleb Koval 870e4e9476
improve 0001
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 6m15s Details
2023-09-10 23:57:43 +01:00
Gleb Koval 763958634e
fix proxmox playbook 2023-09-10 23:54:34 +01:00
Gleb Koval 29906fc462
no handlers
Infrastructure / Check and run Ansbile playbooks (pull_request) Has been cancelled Details
2023-09-10 23:42:26 +01:00
Gleb Koval ab54c18b1b
handlers
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m21s Details
2023-09-10 23:33:43 +01:00
Gleb Koval fce7d91115
debug create
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 6m35s Details
2023-09-10 23:12:18 +01:00
Gleb Koval 20bee24b19
facts are bad
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 6m34s Details
2023-09-09 00:00:30 +01:00
Gleb Koval f891d1e6a8
improve stuff
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m12s Details
2023-09-08 23:58:04 +01:00
Gleb Koval 8406db7eaf
change until:
Infrastructure / Check and run Ansbile playbooks (pull_request) Successful in 3m58s Details
2023-09-08 23:38:17 +01:00
Gleb Koval 2d8ad8f453
now less verbosity 2023-09-08 23:34:08 +01:00
Gleb Koval 599931fd9a
sudo
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 3m27s Details
2023-09-08 23:32:03 +01:00
Gleb Koval 0edaee542f
Better? + qemu-guest-agent
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m46s Details
2023-09-08 23:27:31 +01:00
Gleb Koval b39d99b781
install ping
Infrastructure / Check and run Ansbile playbooks (pull_request) Successful in 2m9s Details
2023-09-07 00:11:49 +01:00
Gleb Koval 9c2ce06cb0
delegate more
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m54s Details
2023-09-07 00:05:11 +01:00
Gleb Koval 18e2ba2f75
hmmmm
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m33s Details
2023-09-07 00:00:36 +01:00
Gleb Koval 04881f9dfa
update apt
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m42s Details
2023-09-06 23:51:08 +01:00
Gleb Koval 19247a2467
get python from apt
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 7s Details
2023-09-06 23:44:02 +01:00
Gleb Koval e12565fdb6
gather facts?
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m39s Details
2023-09-06 23:39:19 +01:00
Gleb Koval 52c0492176
maybe we don't need more python?
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 7s Details
2023-09-06 23:11:04 +01:00
Gleb Koval 0dccf1902a
more testing
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m49s Details
2023-09-06 23:06:36 +01:00
Gleb Koval 1c59a98ec5
testing
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m27s Details
2023-09-06 23:01:30 +01:00
Gleb Koval 7582010748
update hostname
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 1m56s Details
2023-09-06 01:35:34 +01:00
Gleb Koval 54d26948bd
delete wait connection to localhost
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 7m38s Details
2023-09-06 01:11:31 +01:00
Gleb Koval 46de0b3d0f
Revert "debug infra workflow"
This reverts commit f447e9e77e.
2023-09-06 01:10:26 +01:00
Gleb Koval f447e9e77e
debug infra workflow
Infrastructure / Check and run Ansbile playbooks (pull_request) Successful in 3m6s Details
2023-09-06 01:07:15 +01:00
Gleb Koval 4a995ed62e
install ping
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 4m33s Details
2023-09-06 00:47:47 +01:00
Gleb Koval f189b1fca3
move wut
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 3m58s Details
2023-09-06 00:42:08 +01:00
Gleb Koval 152a5a606e
increase verbosity
Infrastructure / Check and run Ansbile playbooks (pull_request) Failing after 3m17s Details
2023-09-06 00:35:08 +01:00
Gleb Koval 381ae8bcf3
stuff 2023-09-06 00:31:45 +01:00
5 changed files with 155 additions and 13 deletions

View File

@ -4,14 +4,15 @@ on:
branches: branches:
- main - main
paths: paths:
- infra/**-playbook.yaml - infra/**playbook.yaml
- .github/workflows/infra.yaml - .github/workflows/infra.yaml
push: push:
branches: branches:
- main - main
env: env:
DEPLOY: ${{ github.ref == 'refs/heads/main' && ((startsWith(github.event.head_commit.message, '[deploy-all]') && 'all') || ('some')) || 'none' }} # DEPLOY: ${{ github.ref == 'refs/heads/main' && ((startsWith(github.event.head_commit.message, '[deploy-all]') && 'all') || ('some')) || 'none' }}
DEPLOY: all
jobs: jobs:
ansible-playbooks: ansible-playbooks:
@ -23,20 +24,17 @@ jobs:
with: with:
fetch-depth: ${{ env.DEPLOY == 'some' && 2 || 1 }} fetch-depth: ${{ env.DEPLOY == 'some' && 2 || 1 }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies - name: Install dependencies
run: | run: |
apt update
apt install -y python3-pip
pip3 install -r requirements.txt pip3 install -r requirements.txt
ansible-galaxy collection install community.general ansible-galaxy collection install community.general
- name: Check playbooks - name: Check playbooks
run: | run: |
for file in $(find . -wholename "*/infra/*-playbook.yaml" -type f); do for file in $(find . -wholename "*/infra/*playbook.yaml" -type f); do
ansible-playbook --inventory ./inventory --check "$file" ansible-playbook --inventory ./inventory --syntax-check "$file"
done done
- name: Get changed playbooks - name: Get changed playbooks
@ -44,7 +42,7 @@ jobs:
if: env.DEPLOY == 'some' if: env.DEPLOY == 'some'
uses: tj-actions/changed-files@v38 uses: tj-actions/changed-files@v38
with: with:
files: infra/**/*-playbook.yaml files: infra/**/*playbook.yaml
- name: Get playbooks - name: Get playbooks
id: playbooks id: playbooks
@ -53,12 +51,19 @@ jobs:
if [[ "${{ env.DEPLOY }}" == "some" ]]; then if [[ "${{ env.DEPLOY }}" == "some" ]]; then
export TO_RUN="${{ steps.files.outputs.all_changed_files }}" export TO_RUN="${{ steps.files.outputs.all_changed_files }}"
else else
export TO_RUN="$(find . -wholename './infra/*-playbook.yaml' -type f)" export TO_RUN="$(find . -wholename './infra/*playbook.yaml' -type f)"
fi fi
export TO_RUN="$( echo -n $TO_RUN | tr ' ' '\n' | sort | tr '\n' ' ' )" # run things in order :) export TO_RUN="$( echo -n $TO_RUN | tr ' ' '\n' | sort | tr '\n' ' ' )" # run things in order :)
echo "will run playbooks: $TO_RUN" echo "will run playbooks: $TO_RUN"
echo "to_run=$TO_RUN" >> "$GITHUB_OUTPUT" echo "to_run=$TO_RUN" >> "$GITHUB_OUTPUT"
- name: Setup environment
if: env.DEPLOY != 'none' && steps.playbooks.outputs.to_run != ''
run: |
mkdir -p -m 700 ~/.ssh
echo "${{ secrets.SSH_PRIVATE }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Run playbooks - name: Run playbooks
if: env.DEPLOY != 'none' && steps.playbooks.outputs.to_run != '' if: env.DEPLOY != 'none' && steps.playbooks.outputs.to_run != ''
env: env:
@ -66,4 +71,5 @@ jobs:
PROXMOX_USER: ${{ secrets.PROXMOX_USER }} PROXMOX_USER: ${{ secrets.PROXMOX_USER }}
PROXMOX_TOKEN_ID: ${{ secrets.PROXMOX_TOKEN_ID }} PROXMOX_TOKEN_ID: ${{ secrets.PROXMOX_TOKEN_ID }}
PROXMOX_TOKEN_SECRET: ${{ secrets.PROXMOX_TOKEN_SECRET }} PROXMOX_TOKEN_SECRET: ${{ secrets.PROXMOX_TOKEN_SECRET }}
SSH_PUBLIC: ${{ secrets.SSH_PUBLIC }}
run: ansible-playbook --inventory ./inventory ${{ steps.playbooks.outputs.to_run }} run: ansible-playbook --inventory ./inventory ${{ steps.playbooks.outputs.to_run }}

View File

@ -7,4 +7,4 @@ This repository contains any automations used in deploying *.koval.net services.
All 'managed' infrastructure is deployed and provisioned with [Ansible](https://www.ansible.com/). All 'managed' infrastructure is deployed and provisioned with [Ansible](https://www.ansible.com/).
However, some 'unmanaged' (manually managed) resources also exist - primarily everything required for this repository to work (I don't want to make a dependency loop). However, some 'unmanaged' (manually managed) resources also exist - primarily everything required for this repository to work (I don't want to make a dependency loop).
Ansible playbooks are ran in alphanumerical order and are expected idempotent. Ansible playbooks are ran in alphanumerical order and are expected to be idempotent.

View File

@ -0,0 +1,104 @@
- name: Provision joplin Proxmox VM
hosts: joplin
connection: ansible.builtin.local
gather_facts: false
vars:
api_user: "{{ lookup('ansible.builtin.env', 'PROXMOX_USER') }}"
api_host: "{{ lookup('ansible.builtin.env', 'PROXMOX_HOST' ) }}"
api_token_id: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_ID') }}"
api_token_secret: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_SECRET') }}"
ssh_public: "{{ lookup('ansible.builtin.env', 'SSH_PUBLIC') }}"
vmname: "{{ inventory_hostname | regex_replace('^([^\\.]+)\\..+$', '\\1') }}"
node: pve
module_defaults:
community.general.proxmox_kvm:
api_user: "{{ api_user }}"
api_host: "{{ api_host }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
name: "{{ vmname }}"
node: "{{ node }}"
community.general.proxmox_nic:
api_user: "{{ api_user }}"
api_host: "{{ api_host }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
name: "{{ vmname }}"
community.general.proxmox_disk:
api_user: "{{ api_user }}"
api_host: "{{ api_host }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
name: "{{ vmname }}"
tasks:
# Initial setup
- name: Create VM
community.general.proxmox_kvm:
clone: "{{ node }}-debian-12"
storage: nvme
register: create
- name: Wait for status
community.general.proxmox_kvm:
state: current
register: vm
retries: 30
delay: 10
until: vm.status is defined
# Networking and initial config
- name: Add HOME NIC
community.general.proxmox_nic:
interface: net0
firewall: false
bridge: HOME
- name: Add SRV NIC
community.general.proxmox_nic:
interface: net1
firewall: false
bridge: SRV
- name: Configure cloud-init
community.general.proxmox_kvm:
update: true
ciuser: debian
sshkeys: "{{ ssh_public }}"
ipconfig:
ipconfig0: ip=dhcp,ip6=auto
ipconfig1: ip=dhcp
# Initial boot
# For some reason debian cloud images don't use
# cloud-init for networking on first boot (cloud-init files
# are regenerated AFTER networking starts). But we need the
# hostname to be registered with DHCP later on so ¯\_(ツ)_/¯
- name: Initial boot
when: create.changed is true
block:
- name: Start
community.general.proxmox_kvm:
state: started
register: start
- name: Wait 3 min # Initial apt update, apt upgrade, cloud-init
ansible.builtin.wait_for:
timeout: 180
# VM Configuration
- name: Resize disk
community.general.proxmox_disk:
disk: scsi0
size: 64G
state: resized
- name: Update VM
community.general.proxmox_kvm:
update: true
agent: enabled=1
tags:
- debian-12
- managed
onboot: true
cores: 2
memory: 2048
- name: Retart VM
community.general.proxmox_kvm:
state: restarted
timeout: 60

View File

@ -0,0 +1,25 @@
- name: Setup Software
hosts: joplin
gather_facts: false
tasks:
- name: Wait for connection
ansible.builtin.wait_for_connection:
timeout: 300
- name: Test some stuff
ansible.builtin.shell: |
touch ~/hmm
echo test > ~/test
echo test2 >> ~/test
mkdir ~/dir
touch ~/dir/testing
- name: Install some stuff
ansible.builtin.apt:
update_cache: true
name: qemu-guest-agent
become: true
- name: Enable some stuff
ansible.builtin.systemd:
name: qemu-guest-agent
state: started
enabled: true
become: true

View File

@ -7,6 +7,13 @@ proxmox:
pve.mgmt.home.local.koval.net: pve.mgmt.home.local.koval.net:
pve2.mgmt.home.local.koval.net: pve2.mgmt.home.local.koval.net:
managed: managed:
hosts: children:
joplin:
hosts:
joplin2.srv.home.local.koval.net:
vars:
ansible_user: debian
ansible_ssh_private_key_file: ~/.ssh/id_rsa
ansible_ssh_common_args: -o StrictHostKeyChecking=accept-new # TODO: Improve this
unmanaged: unmanaged:
hosts: hosts: