feat: deployment for runner
This commit is contained in:
16
Taskfile.yml
16
Taskfile.yml
@@ -8,7 +8,8 @@ tasks:
|
|||||||
|
|
||||||
vault: ansible-vault edit vault.yml {{.CLI_ARGS}}
|
vault: ansible-vault edit vault.yml {{.CLI_ARGS}}
|
||||||
provision: ansible-playbook playbooks/provision.yml {{.CLI_ARGS}}
|
provision: ansible-playbook playbooks/provision.yml {{.CLI_ARGS}}
|
||||||
deploy: ansible-playbook playbooks/deploy.yml {{.CLI_ARGS}}
|
deploy:gitea: ansible-playbook playbooks/deploy.yml {{.CLI_ARGS}}
|
||||||
|
deploy:runner: ansible-playbook playbooks/runner.yml {{.CLI_ARGS}}
|
||||||
restore: ansible-playbook playbooks/restore.yml {{.CLI_ARGS}}
|
restore: ansible-playbook playbooks/restore.yml {{.CLI_ARGS}}
|
||||||
|
|
||||||
assets:
|
assets:
|
||||||
@@ -18,8 +19,13 @@ tasks:
|
|||||||
- cp ./assets/logo.svg ./gitea/custom/public/assets/img/favicon.svg
|
- cp ./assets/logo.svg ./gitea/custom/public/assets/img/favicon.svg
|
||||||
- cp ./assets/logo.png ./gitea/custom/public/assets/img/apple-touch-icon.png
|
- cp ./assets/logo.png ./gitea/custom/public/assets/img/apple-touch-icon.png
|
||||||
|
|
||||||
gitea:
|
enter:gitea:
|
||||||
cmd: ssh -i {{.KEY}} -p 2222 root@{{.IP}}
|
cmd: ssh {{.GITEA}}
|
||||||
vars:
|
vars:
|
||||||
KEY: { sh: ansible-vault view vault.yml | yq -r ".secret.private_gitea_ssh_key_path" }
|
GITEA: { sh: cat ./variables.yml | yq -r ".variables.gitea_host" }
|
||||||
IP: { sh: cat dist/terraform_outputs.yml | jq -r ".server_ip.value" }
|
|
||||||
|
enter:runner:
|
||||||
|
cmd: ssh -J {{.GITEA}} {{.RUNNER}}
|
||||||
|
vars:
|
||||||
|
GITEA: { sh: cat ./variables.yml | yq -r ".variables.gitea_host" }
|
||||||
|
RUNNER: { sh: cat ./variables.yml | yq -r ".variables.runner_host" }
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
- name: Add remote host.
|
- name: Add remote host.
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: server
|
name: server
|
||||||
ansible_ssh_host: repository_gitea
|
ansible_ssh_host: "{{ variables.gitea_host }}"
|
||||||
|
|
||||||
- name: Install Docker.
|
- name: Install Docker.
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
@@ -55,6 +55,7 @@
|
|||||||
name:
|
name:
|
||||||
- python3-pip
|
- python3-pip
|
||||||
state: present
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
- name: Install needed packages.
|
- name: Install needed packages.
|
||||||
ansible.builtin.pip:
|
ansible.builtin.pip:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
- name: Add remote host.
|
- name: Add remote host.
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: server
|
name: server
|
||||||
ansible_ssh_host: repository_gitea
|
ansible_ssh_host: "{{ variables.gitea_host }}"
|
||||||
|
|
||||||
- name: Deploy artifact to instance.
|
- name: Deploy artifact to instance.
|
||||||
hosts: server
|
hosts: server
|
||||||
|
|||||||
@@ -1,25 +1,113 @@
|
|||||||
- name: Set up for fresh host.
|
- name: Set up for fresh host.
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
|
vars_files:
|
||||||
|
- ../vault.yml
|
||||||
|
- ../variables.yml
|
||||||
|
tasks:
|
||||||
|
- name: Add runner host.
|
||||||
|
ansible.builtin.add_host:
|
||||||
|
name: runner
|
||||||
|
ansible_ssh_host: "{{ variables.runner_host }}"
|
||||||
|
ansible_ssh_extra_args: "-J {{ variables.gitea_host }}"
|
||||||
|
|
||||||
|
- name: Add Gitea host.
|
||||||
|
ansible.builtin.add_host:
|
||||||
|
name: gitea
|
||||||
|
ansible_ssh_host: "{{ variables.gitea_host }}"
|
||||||
|
|
||||||
|
- name: Install Docker.
|
||||||
|
gather_facts: true
|
||||||
|
hosts: runner
|
||||||
vars_files:
|
vars_files:
|
||||||
- ../vault.yml
|
- ../vault.yml
|
||||||
- ../dist/terraform_outputs.yml
|
- ../dist/terraform_outputs.yml
|
||||||
tasks:
|
tasks:
|
||||||
- name: Add remote host.
|
- name: Install PIP.
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.apt:
|
||||||
name: server
|
name:
|
||||||
ansible_ssh_host: repository_runner
|
- python3-pip
|
||||||
ansible_ssh_extra_args: -J repository_gitea
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
- name: Deploy runner.
|
- name: Install needed packages.
|
||||||
hosts: server
|
ansible.builtin.pip:
|
||||||
|
name:
|
||||||
|
- botocore
|
||||||
|
- boto3
|
||||||
|
- packaging
|
||||||
|
state: present
|
||||||
|
break_system_packages: true
|
||||||
|
|
||||||
|
- name: Download Docker repository key.
|
||||||
|
ansible.builtin.apt_key:
|
||||||
|
url: https://download.docker.com/linux/debian/gpg
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Download Docker repository.
|
||||||
|
ansible.builtin.apt_repository:
|
||||||
|
repo: "deb https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Remove bad packages.
|
||||||
|
ansible.builtin.apt:
|
||||||
|
state: absent
|
||||||
|
package:
|
||||||
|
- docker.io
|
||||||
|
- docker-doc
|
||||||
|
- docker-compose
|
||||||
|
- podman-docker
|
||||||
|
- containerd
|
||||||
|
- runc
|
||||||
|
|
||||||
|
- name: Download Docker dependencies.
|
||||||
|
ansible.builtin.apt:
|
||||||
|
state: present
|
||||||
|
package:
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
|
||||||
|
- name: Download Docker packages.
|
||||||
|
ansible.builtin.apt:
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
package:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
- docker-buildx-plugin
|
||||||
|
- docker-compose-plugin
|
||||||
|
|
||||||
|
- name: Get registration token for Runner.
|
||||||
|
hosts: gitea
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
- name: Test
|
- name: Get registration token.
|
||||||
ansible.builtin.raw: hostname
|
community.docker.docker_container_exec:
|
||||||
register: test
|
container: server
|
||||||
changed_when: false
|
command: gitea actions grt
|
||||||
|
register: output
|
||||||
|
|
||||||
- name: Debug
|
- name: Set fact.
|
||||||
ansible.builtin.debug:
|
ansible.builtin.set_fact:
|
||||||
var: test
|
registration_token: "{{ output.stdout }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
delegate_facts: true
|
||||||
|
|
||||||
|
- name: Deploy Runner.
|
||||||
|
hosts: runner
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: Deploy image.
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: runner
|
||||||
|
image: docker.io/gitea/act_runner:nightly
|
||||||
|
env:
|
||||||
|
CONFIG_FILE: /config.yaml
|
||||||
|
GITEA_INSTANCE_URL: git.maximhutz.com
|
||||||
|
GITEA_RUNNER_REGISTRATION_TOKEN: "{{ hostvars['localhost']['registration_token'] }}"
|
||||||
|
GITEA_RUNNER_NAME: "Main Runner"
|
||||||
|
volumes:
|
||||||
|
- ./config.yaml:/config.yaml
|
||||||
|
- ./data:/data
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|||||||
Reference in New Issue
Block a user