Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alorle committed Mar 25, 2024
0 parents commit dbb64be
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: CI

'on':
pull_request:
push:
branches:
- main

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out codebase.
uses: actions/checkout@v4

- name: Run ansible-lint
uses: ansible/ansible-lint@main

- name: Run yamllint
uses: frenck/action-yamllint@v1
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Release

'on':
push:
tags:
- '*'

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out codebase.
uses: actions/checkout@v4

- name: galaxy
uses: robertdebock/[email protected]
with:
galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}
7 changes: 7 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
extends: default

rules:
line-length:
max: 120
level: warning
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Podman Install

Ansible role to install podman on Debian based distros using [home:alvistack](https://build.opensuse.org/project/show/home:alvistack) repository.

## Requirements

None.

## Role Variables

Available variables are listed below, along with default values (see [defaults/main.yml](defaults/main.yml)):

| Variable | Description | Default value |
| ------------------------- | ------------------------------------------------- | ------------- |
| `podman_install_packages` | List of packages to be installed within the role. | `["podman"]` |
| `podman_service_state` | Podman service's state after role execution. | `started` |
| `podman_service_enabled` | Wheter to enable podman service at boot. | `true` |

## Dependencies

None.

## Example Playbook

```yaml
- hosts: servers
vars:
podman_install_packages:
- podman>=4.4
- crun
roles:
- alorle.podman_install
```
## License
MIT
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
podman_install_packages:
- podman
podman_service_state: started
podman_service_enabled: true
5 changes: 5 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Restart podman
ansible.builtin.service:
name: podman.service
state: restarted
20 changes: 20 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
galaxy_info:
role_name: podman_install
namespace: alorle
author: Álvaro Orduna León
description: Ansible Role for Podman Installation on Debian distributions
license: license MIT
min_ansible_version: "2.1"
platforms:
- name: Ubuntu
versions:
- all
- name: Debian
versions:
- all
galaxy_tags:
- system
- podman
- debian
- ubuntu
43 changes: 43 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
- name: Ensure os family is Debian.
ansible.builtin.assert:
that: "ansible_os_family =='Debian'"

- name: Define repository base path.
block:
- name: Define Ubuntu repository base path.
ansible.builtin.set_fact:
repository_base_path: "xUbunut_{{ ansible_facts.distribution_version }}"
when: ansible_facts.distribution == "Ubuntu"
- name: Define Debian repository base path.
ansible.builtin.set_fact:
repository_base_path: "Debian_{{ ansible_facts.distribution_major_version }}"
when: ansible_facts.distribution != "Ubuntu"

- name: Ensure apt key is installed.
ansible.builtin.apt_key:
id: "{{ podman_apt_key.id | default(omit) }}"
url: "{{ podman_apt_key.url }}"
keyring: "{{ podman_apt_key.keyring }}"
state: "{{ podman_apt_key.state | default('present') }}"

- name: Ensure apt repository file is present.
ansible.builtin.apt_repository:
filename: "{{ podman_apt_repository.filename }}"
repo: "{{ podman_apt_repository.repo }}"
mode: "{{ podman_apt_repository.mode | default('0644') }}"
state: "{{ podman_apt_repository.state | default('present') }}"

- name: Ensure apt packages are installed.
ansible.builtin.package:
name: "{{ item }}"
state: present
loop: "{{ podman_install_packages }}"
notify: Restart podman

- name: Ensure podman is started and enabled at boot.
ansible.builtin.service:
name: podman
state: "{{ podman_service_state }}"
enabled: "{{ podman_service_enabled }}"
ignore_errors: "{{ ansible_check_mode }}"
8 changes: 8 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
podman_apt_key:
keyring: /etc/apt/trusted.gpg.d/home_alvistack.gpg
url: http://downloadcontent.opensuse.org/repositories/home:/alvistack/{{ repository_base_path }}/Release.key

podman_apt_repository:
filename: home:alvistack
repo: deb http://downloadcontent.opensuse.org/repositories/home:/alvistack/{{ repository_base_path }}/ /

0 comments on commit dbb64be

Please sign in to comment.