ansible-woodpecker-role/tasks/main.yml
2021-12-19 23:44:51 +01:00

72 lines
1.9 KiB
YAML

---
- name: Create rootdir
ansible.builtin.file:
path: "{{ woodpecker_rootdir }}"
state: directory
owner: root
group: root
mode: 0755
- name: Template server.env-file
ansible.builtin.template:
src: server.env.j2
dest: "{{ woodpecker_rootdir }}/server.env"
owner: root
group: root
mode: 0644
- name: Create the woodpecker network
community.docker.docker_network:
name: woodpecker-net
- name: Create and start the woodpecker-server container
community.docker.docker_container:
name: woodpecker-server
restart_policy: always
pull: true
cap_drop: all
networks:
- name: woodpecker-net
published_ports:
- 80:80
- 443:443
volumes:
- "{{ woodpecker_rootdir }}/data:/var/lib/woodpecker"
env_file: "{{ woodpecker_rootdir }}/server.env"
image: "woodpeckerci/woodpecker-server:{{ woodpecker_version }}"
- name: Create and start the woodpecker-agent container
community.docker.docker_container:
name: woodpecker-agent
restart_policy: always
pull: true
cap_drop: all
networks:
- name: woodpecker-net
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
env:
WOODPECKER_SERVER: woodpecker-server:9000
WOODPECKER_AGENT_SECRET: "{{ woodpecker_agent_secret }}"
WOODPECKER_MAX_PROCS: "{{ woodpecker_agent_max_procs }}"
image: "woodpeckerci/woodpecker-agent:{{ woodpecker_version }}"
- name: Create and start the watchtower container if wanted
docker_container:
name: watchtower
restart_policy: always
pull: true
networks:
- name: woodpecker-net
userns_mode: host
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
env:
WATCHTOWER_CLEANUP: "true"
WATCHTOWER_SCHEDULE: "{{ woodpecker_watchtower_schedule }}"
WATCHTOWER_NO_STARTUP_MESSAGE: "true"
TZ: Europe/Berlin
image: containrrr/watchtower:latest
when: woodpecker_watchtower | bool