Skip to content

Commit

Permalink
feat(provisioner): Setup playbook (#666)
Browse files Browse the repository at this point in the history
* feat(provisioner): Setup playbook

* Working playbook with Tailscale host

* Add linter for Ansible

* Disable announce for Trunk CLI
  • Loading branch information
mvgijssel authored Nov 16, 2024
1 parent 708ebd1 commit 7d3b0e8
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 14 deletions.
12 changes: 10 additions & 2 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ runtimes:
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
Expand All @@ -38,17 +39,18 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
disabled:
# Disabled explicitly because I think these break the integration with Trunk and VSCode
- hadolint
- trufflehog
actions:
enabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
disabled:
- trunk-announce
tools:
disabled:
- poetry
Expand All @@ -64,6 +66,7 @@ tools:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
definitions:
- name: bazelisk
download: bazelisk
Expand Down Expand Up @@ -100,6 +103,11 @@ tools:
shims:
- name: devspace
target: devspace
- name: ansible
runtime: python
package: ansible
shims: [ansible, ansible-playbook, ansible-galaxy]
known_good_version: 10.6.0

downloads:
- name: bazelisk
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"files.exclude": {
"**/bazel-*": true,
"haos/custom_components/hacs/**/*": true
}
},
"trunk.autoInit": false
}
10 changes: 0 additions & 10 deletions ansible/filter_plugins/not_falsy.py

This file was deleted.

Empty file added ansible/group_vars/all.yml
Empty file.
4 changes: 4 additions & 0 deletions ansible/group_vars/provisioner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ansible_python_interpreter: /usr/bin/python
ansible_user: root
ansible_become: false
ansible_remote_tmp: /tmp/
2 changes: 2 additions & 0 deletions ansible/production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[provisioner]
provisioner
4 changes: 4 additions & 0 deletions ansible/provisioner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- hosts: provisioner
roles:
- pikvm
28 changes: 28 additions & 0 deletions ansible/roles/pikvm/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- name: Update PiKVM
block:
- name: Remount read-write to prepare for changes
ansible.builtin.command: rw
changed_when: false
when: not ansible_check_mode

- name: Generate PiKVM config
ansible.builtin.template:
src: meta.yml.j2
dest: /etc/kvmd/meta.yaml
group: root
owner: root
mode: "0644"
vars:
pikvm_hostname: "{{ ansible_hostname }}"

rescue:
- name: Something went wrong
ansible.builtin.debug:
msg: An error occured
when: not ansible_check_mode

always:
- name: Remount read-only
ansible.builtin.command: ro
changed_when: false
when: not ansible_check_mode
9 changes: 9 additions & 0 deletions ansible/roles/pikvm/templates/meta.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# You can write down any information and it will be available
# at the address /api/info (if you use default nginx config).
# If server.host (str) will be defined then this value
# will be displayed in the web interface.

server:
host: {{ pikvm_hostname }}

kvm: {}
2 changes: 2 additions & 0 deletions ansible/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
- import_playbook: provisioner.yml
3 changes: 2 additions & 1 deletion devenv/deploys/editor/files/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@
"**/.trunk/*out/": true,
"**/.trunk/*plugins/": true
},
"editor.defaultFormatter": "trunk.io"
"editor.defaultFormatter": "trunk.io",
"trunk.autoInit": false
}

0 comments on commit 7d3b0e8

Please sign in to comment.