Skip to content

Commit

Permalink
feat: Add tc_redirect_tap role (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazysgurskas authored Nov 21, 2023
1 parent dac3663 commit db86ce1
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
27 changes: 27 additions & 0 deletions roles/tc_redirect_tap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# tc_redirect_tap

Ansible role to install and configure [tc-redirect-tap](https://github.com/awslabs/tc-redirect-tap).

## Requirements

None.

## Dependencies

None.

## Role Variables

Refer to [defaults/main.yml](defaults/main.yml) for a list of variables along with documentation.

## Example Playbook

```yaml
- hosts: all
roles:
- role: hostinger.core.tc_redirect_tap
```
## License
See [LICENSE](../../LICENSE)
10 changes: 10 additions & 0 deletions roles/tc_redirect_tap/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
tc_redirect_tap_version: 0.0.1
tc_redirect_tap_url: |
https://github.com/hostinger/tc-redirect-tap/releases/download/v{{ tc_redirect_tap_version }}/tc-redirect-tap-{{ tc_redirect_tap_arch }}
tc_redirect_tap_owner: root
tc_redirect_tap_group: root
tc_redirect_tap_arch: amd64
tc_redirect_tap_dir: /opt/tc-redirect-tap
tc_redirect_tap_install_dir: "{{ tc_redirect_tap_dir }}/{{ tc_redirect_tap_version }}"
tc_redirect_tap_bin_dir: "{{ tc_redirect_tap_dir }}/bin"
20 changes: 20 additions & 0 deletions roles/tc_redirect_tap/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
galaxy_info:
role_name: tc_redirect_tap
author: hostinger
description: Ansible role for installing tc-redirect-tap CNI plugin
license: license (MIT)
min_ansible_version: "2.10"
platforms:
- name: Fedora
versions:
- all
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
galaxy_tags:
- cni-plugins
- tc-redirect-tap
7 changes: 7 additions & 0 deletions roles/tc_redirect_tap/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts:
- all

roles:
- tc_redirect_tap
19 changes: 19 additions & 0 deletions roles/tc_redirect_tap/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: default
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
pre_build_image: true
privileged: true
platform: amd64
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
36 changes: 36 additions & 0 deletions roles/tc_redirect_tap/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Fail when unsupported architecture
ansible.builtin.fail:
msg: "Unsupported architecture"
when:
- tc_redirect_tap_arch not in ['amd64', 'arm64']

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
mode: 0755
state: directory
owner: "{{ tc_redirect_tap_owner }}"
group: "{{ tc_redirect_tap_group }}"
with_items:
- "{{ tc_redirect_tap_dir }}"
- "{{ tc_redirect_tap_install_dir }}"
- "{{ tc_redirect_tap_bin_dir }}"

- name: Download binary
ansible.builtin.get_url:
url: "{{ tc_redirect_tap_url }}"
dest: "{{ tc_redirect_tap_install_dir }}/tc-redirect-tap"
mode: 0755
owner: "{{ tc_redirect_tap_owner }}"
group: "{{ tc_redirect_tap_group }}"
timeout: 30

- name: Create symlink to binaries
ansible.builtin.file:
src: "{{ tc_redirect_tap_install_dir }}/tc-redirect-tap"
dest: "{{ tc_redirect_tap_bin_dir }}/tc-redirect-tap"
mode: 0755
owner: "{{ tc_redirect_tap_owner }}"
group: "{{ tc_redirect_tap_group }}"
state: link

0 comments on commit db86ce1

Please sign in to comment.