From 95b73daa36b23565a8566f71f9b202d3459b685f Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 25 Jun 2023 09:52:36 -0400 Subject: Initial Commit --- roles/services/containers/renovate/tasks/main.yml | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 roles/services/containers/renovate/tasks/main.yml (limited to 'roles/services/containers/renovate/tasks') diff --git a/roles/services/containers/renovate/tasks/main.yml b/roles/services/containers/renovate/tasks/main.yml new file mode 100644 index 0000000..bbbfe11 --- /dev/null +++ b/roles/services/containers/renovate/tasks/main.yml @@ -0,0 +1,87 @@ +- name: set image fact + set_fact: + image: renovate/renovate:35.141.3-slim + +- name: set other facts + vars: + array: "{{ image.split('/', 1) }}" + set_fact: + repo_tag: "{{ array.1 }}" + custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" + +- name: create renovate directory + file: + path: "{{ docker_home }}/renovate" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: create renovate docker network + become: yes + become_user: "{{ docker_username }}" + docker_network: + name: "{{ renovate_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ renovate_subnet }}" + gateway: "{{ renovate_gateway }}" + +- name: pull and push renovate image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + push: yes + +- name: create and deploy renovate container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "renovate" + image: "{{ custom_registry }}/{{ repo_tag }}" + pull: yes + recreate: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ renovate_network_name }}" + ipv4_address: "{{ renovate_ipv4 }}" + env: + "RENOVATE_ENDPOINT": "{{ renovate_endpoint }}" + "RENOVATE_PLATFORM": "gitea" + "RENOVATE_TOKEN": "{{ renovate_token }}" + "RENOVATE_AUTODISCOVER": "true" + "LOG_LEVEL": "debug" + "RENOVATE_GIT_AUTHOR": "{{ renovate_author }}" + restart_policy: "no" + state: 'started' + + +- name: create cron job to run renovate container daily + cron: + name: "run renovate" + job: "docker start renovate" + user: "{{ docker_username }}" + minute: "0" + hour: "6" -- cgit v1.2.3