114 lines
2.9 KiB
YAML
114 lines
2.9 KiB
YAML
- name: Set up for fresh host.
|
|
gather_facts: false
|
|
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:
|
|
- ../vault.yml
|
|
- ../dist/terraform_outputs.yml
|
|
tasks:
|
|
- name: Install PIP.
|
|
ansible.builtin.apt:
|
|
name:
|
|
- python3-pip
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Install needed packages.
|
|
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
|
|
tasks:
|
|
- name: Get registration token.
|
|
community.docker.docker_container_exec:
|
|
container: server
|
|
command: gitea actions grt
|
|
register: output
|
|
|
|
- name: Set fact.
|
|
ansible.builtin.set_fact:
|
|
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
|