-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prepare role ansible-role-exabgp-docker
- Loading branch information
1 parent
64e94a6
commit 828d143
Showing
8 changed files
with
247 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,56 @@ | ||
# ansible-role-exabgp-docker | ||
# exabgp_docker | ||
|
||
Role for setting up a docker running exabgp. | ||
Configuration is done by the added files and templates(Not part of this role). | ||
|
||
## Requirements | ||
|
||
- Setting up network interfaces must be done before running this role. | ||
|
||
## Role Variables | ||
|
||
- exabgp_path - Base path where the files will be copied or created | ||
- exabgp_dirs - List of directories which will be created (Path is relative to /) | ||
- Example value: `- { path: "{{ exabgp_path }}" }` | ||
- exabgp_files - List of files which will be copied to machine | ||
- Example value: `- {src: "", dest: "", user: "", group: "", mode: ""}` where: | ||
- src - required | ||
- dest - optional; Default value: same as src; Relative to `exabgp_path` | ||
- user - optional; Default value: root | ||
- group - optional; Default value: root | ||
- mode - optional; Default value: 0644 | ||
- exabgp_templates - List of templates | ||
- Example value: `- {src: "", dest: "", user: "", group: "", mode: ""}` where: | ||
- src - required | ||
- dest - optional; Default value: same as src; Relative to `exabgp_path` | ||
- user - optional; Default value: root | ||
- group - optional; Default value: root | ||
- mode - optional; Default value: 0644 | ||
- exabgp_docker_compose_template - Name of the used docker-compose template | ||
- Relative to the folder with templates | ||
- exabgp_custom_volumes - List of volumes connected to docker | ||
- Only for default docker_compose_template | ||
- Example value: `- "/etc/docker/data_volume:/data_volume"` | ||
- exabgp_docker_image - Name of the docker image | ||
- Only for default docker_compose_template | ||
|
||
## Dependencies | ||
|
||
-- | ||
|
||
## Example Playbook | ||
|
||
- hosts: all | ||
roles: | ||
- cesnet.exabgp_docker | ||
|
||
## Tags | ||
|
||
- `exabgp` - Runs all task to create directories, copy files, create files from templates and run docker with ExaBGP | ||
- `exabgp_start` - Try to start docker with ExaBGP | ||
- `exabgp_stop` - Try to stop docker with ExaBGP | ||
- `exabgp_restart` - Try to restart docker with ExaBGP | ||
|
||
## Author Information | ||
|
||
Pavel Vyskocil <[email protected]>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
# defaults file for cesnet.exabgp_docker | ||
|
||
# Base path where the files will be copied or created | ||
exabgp_path: "/opt/exabgp" | ||
|
||
# List of directories which will be created (Path is relative to /) | ||
exabgp_dirs: | ||
- { path: "{{ exabgp_path }}" } | ||
- { path: "{{ exabgp_path }}/etc" } | ||
- { path: "{{ exabgp_path }}/etc/exabgp" } | ||
|
||
# List of files which will be copied to machine | ||
# - Example value: - {src: "", dest: "", user: "", group: "", mode: ""} where: | ||
# - src - required | ||
# - dest - optional; Default value: same as src; Relative to exabgp_path | ||
# - user - optional; Default value: root | ||
# - group - optional; Default value: root | ||
# - mode - optional; Default value: 0644 | ||
exabgp_files: [] | ||
|
||
#- exabgp_templates - List of templates | ||
# - Example value: - {src: "", dest: "", user: "", group: "", mode: ""} where: | ||
# - src - required | ||
# - dest - optional; Default value: same as src; Relative to exabgp_path | ||
# - user - optional; Default value: root | ||
# - group - optional; Default value: root | ||
# - mode - optional; Default value: 0644 | ||
exabgp_templates: [] | ||
|
||
# Name of the used docker-compose template | ||
exabgp_docker_compose_template: "default-docker-compose.yml" | ||
|
||
# List of volumes connected to docker | ||
# - Only for default docker_compose_template | ||
# - Example value: `- "/etc/docker/data_volume:/data_volume"` | ||
exabgp_custom_volumes: [] | ||
|
||
# Name of the docker image | ||
# - Only for default docker_compose_template | ||
exabgp_docker_image: "pierky/exabgp:4.2.7" | ||
|
||
# If TRUE, exabgp docker will be started/restarted | ||
# If FALSE, exabgp docker will not be started/restarted | ||
exabgp_force_start: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
# handlers file for cesnet.exabgp | ||
|
||
- name: "EXABGP - Restart" | ||
community.docker.docker_compose_v2: | ||
project_src: "{{ exabgp_path }}" | ||
state: restarted | ||
when: exabgp_force_start == True | ||
listen: "docker exabgp restart" | ||
|
||
- name: "EXABGP - Force Restart" | ||
community.docker.docker_compose_v2: | ||
project_src: "{{ exabgp_path }}" | ||
state: restarted | ||
listen: "docker exabgp force restart" | ||
|
||
- name: "EXABGP - Stop" | ||
community.docker.docker_compose_v2: | ||
project_src: "{{ exabgp_path }}" | ||
state: absent | ||
listen: "docker exabgp stop" | ||
|
||
- name: "EXABGP - Start" | ||
community.docker.docker_compose_v2: | ||
project_src: "{{ exabgp_path }}" | ||
state: present | ||
pull: always | ||
when: exabgp_force_start == True | ||
listen: "docker exabgp start" | ||
|
||
- name: "EXABGP - Force Start" | ||
community.docker.docker_compose_v2: | ||
project_src: "{{ exabgp_path }}" | ||
state: present | ||
pull: always | ||
listen: "docker exabgp force start" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
- name: "EXABGP - Get interfaces" | ||
shell: ifconfig -a | ||
register: network_interfaces | ||
|
||
- name: "EXABGP - print" | ||
debug: | ||
msg: "{{ network_interfaces.stdout_lines }}" | ||
|
||
- name: "EXABGP - Confirm interfaces" | ||
pause: | ||
prompt: "Please check if network interfaces above are correct.\n\nPress any key to continue[Ctrl+C and then 'A' for abort]" | ||
when: force == false | ||
|
||
- name: "EXABGP - Ensure that directory are created" | ||
file: | ||
path: "{{ item.path }}" | ||
owner: "{{ item.owner | default('root') }}" | ||
group: "{{ item.group | default('root') }}" | ||
mode: "{{ item.mode | default('0755') }}" | ||
state: directory | ||
loop: "{{ exabgp_dirs }}" | ||
|
||
- name: "EXABGP - Copy files" | ||
copy: | ||
src: "{{ item.src }}" | ||
dest: "{{ exabgp_path }}/{{ item.dest | default(item.src) }}" | ||
owner: "{{ item.owner | default('root') }}" | ||
group: "{{ item.group | default('root') }}" | ||
mode: "{{ item.mode | default('0644') }}" | ||
loop: "{{ exabgp_files }}" | ||
notify: "docker exabgp restart" | ||
|
||
- name: "EXABGP - Create files from template" | ||
template: | ||
src: "{{ item.src }}.j2" | ||
dest: "{{ exabgp_path }}/{{ item.dest | default(item.src) }}" | ||
owner: "{{ item.owner | default('root') }}" | ||
group: "{{ item.group | default('root') }}" | ||
mode: "{{ item.mode | default('0644') }}" | ||
loop: "{{ exabgp_templates }}" | ||
notify: "docker exabgp restart" | ||
|
||
- name: "EXABGP - Create docker-compose.yml from template" | ||
template: | ||
src: "{{ exabgp_docker_compose_template }}.j2" | ||
dest: "{{ exabgp_path }}/docker-compose.yml" | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
tags: | ||
- upgrade_docker_containers | ||
- exabgp_upgrade_docker_container | ||
notify: "docker exabgp restart" | ||
|
||
- name: "EXABGP - Ensure that docker image is started" | ||
command: /bin/true | ||
notify: "docker exabgp start" | ||
when: exabgp_force_start == True | ||
tags: | ||
- upgrade_docker_containers | ||
- exabgp_upgrade_docker_container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: "EXABGP - RESTART docker" | ||
command: /bin/true | ||
tags: | ||
- "never" | ||
- "exabgp_restart" | ||
notify: "docker exabgp force restart" | ||
|
||
- name: "EXABGP - STOP docker" | ||
command: /bin/true | ||
tags: | ||
- "never" | ||
- "exabgp_stop" | ||
notify: "docker exabgp stop" | ||
|
||
- name: "EXABGP - START docker" | ||
command: /bin/true | ||
tags: | ||
- "never" | ||
- "exabgp_start" | ||
notify: "docker exabgp force start" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
# tasks file for cesnet.exabgp | ||
- import_tasks: exabgp.yml | ||
tags: | ||
- exabgp | ||
|
||
- import_tasks: exabgp_controls.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{ ansible_managed | comment}} | ||
|
||
services: | ||
exabgp: | ||
image: {{ exabgp_docker_image }} | ||
container_name: exabgp | ||
volumes: | ||
- {{ exabgp_path }}/etc/exabgp:/etc/exabgp:rw | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
{% for volume in exabgp_custom_volumes | default([]) %} | ||
- {{ volume }} | ||
{% endfor %} | ||
network_mode: host | ||
restart: always | ||
logging: | ||
driver: "syslog" | ||
options: | ||
tag: "proxyaai/exabgp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# vars file for cesnet.exabgp |