Skip to content

Commit

Permalink
feat: Add nerdctl role
Browse files Browse the repository at this point in the history
  • Loading branch information
konradasb committed Nov 9, 2023
1 parent 40e3d25 commit ffb89d5
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
27 changes: 27 additions & 0 deletions roles/nerdctl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# nerdctl

Ansible role to install and configure [nerdctl](https://github.com/containerd/nerdctl).

## 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.nerdctl
```
## License
See [LICENSE](../../LICENSE)
9 changes: 9 additions & 0 deletions roles/nerdctl/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
nerdctl_version: 1.7.0
nerdctl_url: |
https://github.com/containerd/nerdctl/releases/download/v{{ nerdctl_version }}/nerdctl-{{ nerdctl_version }}-{{ nerdctl_os }}-{{ nerdctl_arch }}.tar.gz
nerdctl_arch: amd64
nerdctl_os: linux
nerdctl_install_dir: /opt/nerdctl/{{ nerdctl_version }}
nerdctl_owner: root
nerdctl_group: root
19 changes: 19 additions & 0 deletions roles/nerdctl/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
galaxy_info:
role_name: nerdctl
author: hostinger
description: Ansible role for installing nerdctl
license: license (MIT)
min_ansible_version: "2.10"
platforms:
- name: Fedora
versions:
- all
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
galaxy_tags:
- nerdctl
7 changes: 7 additions & 0 deletions roles/nerdctl/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts:
- all

roles:
- nerdctl
19 changes: 19 additions & 0 deletions roles/nerdctl/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}
34 changes: 34 additions & 0 deletions roles/nerdctl/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Create directory
ansible.builtin.file:
name: "{{ nerdctl_install_dir }}"
mode: 0755
owner: "{{ nerdctl_owner }}"
group: "{{ nerdctl_group }}"
state: directory

- name: Download tarball
ansible.builtin.get_url:
url: "{{ nerdctl_url }}"
dest: "{{ nerdctl_install_dir }}/nerdctl.tar.gz"
mode: 0644
owner: "{{ nerdctl_owner }}"
group: "{{ nerdctl_group }}"
timeout: 30

- name: Unarchive tarball
ansible.builtin.unarchive:
src: "{{ nerdctl_install_dir }}/nerdctl.tar.gz"
remote_src: true
dest: "{{ nerdctl_install_dir }}"
creates: "{{ nerdctl_install_dir }}/nerdctl"
owner: "{{ nerdctl_owner }}"
group: "{{ nerdctl_group }}"

- name: Create symlink to binary
ansible.builtin.file:
src: "{{ nerdctl_install_dir }}/nerdctl"
dest: /usr/local/bin/nerdctl
mode: 0755
state: link
force: true

0 comments on commit ffb89d5

Please sign in to comment.