inital commit

This commit is contained in:
Lennard Brinkhaus 2023-09-08 22:41:09 +02:00
commit 8a1e996808
Signed by: lennard.brinkhaus
GPG Key ID: 286421EC53998B22
26 changed files with 592 additions and 0 deletions

19
.editorconfig Normal file
View File

@ -0,0 +1,19 @@
# EditorConfig: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Defaults for all editor files
[*]
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
# Files with a smaller indent
[*.yml]
indent_size = 2
# Jinja2 template files
[*.j2]
end_of_line = lf

20
.gitignore vendored Normal file
View File

@ -0,0 +1,20 @@
local-configure.yml
.vagrant/
docs/_build/
roles/plone.plone_server
roles/jnv.unattended-upgrades
roles/tersmitten.fail2ban
roles/ANXS.hostname
roles/ANXS.apt
._*
bin/
lib/
include/
local/
tests.out
*.retry
*.log
vbox_host.cfg
.DS_Store
*.py[co]
.idea/

38
README.md Normal file
View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

2
ansible.cfg Normal file
View File

@ -0,0 +1,2 @@
[defaults]
roles_path: ./../

22
defaults/main.yml Normal file
View File

@ -0,0 +1,22 @@
---
podman_version_check: true
podman_version: "4.6.0"
podman_netavark_version: "v1.7.0"
podman_conmon_version: "v2.1.7"
podman_aardvark_dns_version: "v1.7.0"
podman_crun_version: "1.8.5"
podman_buildpath: "/tmp/podman"
podman_conmon_buildpath: "{{ podman_buildpath }}/conmon"
podman_aardvark_dns_buildpath: "{{ podman_buildpath }}/aardvark_dns"
podman_crun_buildpath: "{{ podman_buildpath }}/crun"
podman_podman_buildpath: "{{ podman_buildpath }}/podman"
podman_netavark_buildpath: "{{ podman_buildpath }}/netavark"
podman_containers_config: "/etc/containers"
podman_netavark_repopath: "https://github.com/containers/netavark.git"
podman_aardvark_dns_repopath: "https://github.com/containers/aardvark-dns.git"
podman_crun_repopath: "https://github.com/containers/crun.git"
podman_conmon_repopath: "https://github.com/containers/conmon"
podman_podman_repopath: "https://github.com/containers/podman"

6
handlers/main.yml Normal file
View File

@ -0,0 +1,6 @@
---
# handlers file for role-podman
- name: "Reload systemd"
ansible.builtin.systemd:
daemon_reload: true
when: ansible_service_mgr == "systemd"

40
meta/main.yml Normal file
View File

@ -0,0 +1,40 @@
galaxy_info:
role_name: podman
namespace: dragse
author: Lennard Brinkhaus
description: Install and manage PHP
company: DragSE
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
min_ansible_version: "2.1"
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
license: None
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
galaxy_tags:
- podman
dependencies:
- role-golang
- role-rust
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

4
meta/requirements.yml Normal file
View File

@ -0,0 +1,4 @@
- name: role-golang
src: https://git.dragse.it/ansible/role-golang
- name: role-rust
src: https://git.dragse.it/ansible/role-rust

40
tasks/configure.yml Normal file
View File

@ -0,0 +1,40 @@
- name: "Create conatiners folder"
file:
path: "{{ podman_containers_config }}"
state: directory
mode: 'u=rwx,g=rx,o='
- name: "Create config and data directory"
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: '0755'
with_items:
- "{{ podman_containers_config }}"
- "{{ podman_containers_config }}/registries.conf.d"
- name: Copy policy.json
ansible.builtin.template:
src: policy.json
dest: "{{ podman_containers_config }}/policy.json"
mode: 0600
- name: Copy registries.json
ansible.builtin.template:
src: registries.conf
dest: "{{ podman_containers_config }}/registries.conf"
mode: 0600
- name: "Create registries.conf.d folder"
file:
path: "{{ podman_containers_config }}/registries.conf.d"
state: directory
mode: 'u=rwx,g=rx,o='
- name: Copy registries.json
ansible.builtin.template:
src: registries.conf.d/shortnames.conf
dest: "{{ podman_containers_config }}/registries.conf.d/shortnames.conf"
mode: 0600

8
tasks/install.yml Normal file
View File

@ -0,0 +1,8 @@
---
- include_tasks: install_depens.yml
- include_tasks: install_conmon.yml
- include_tasks: install_netavark.yml
- include_tasks: install_aardvark_dns.yml

View File

@ -0,0 +1,26 @@
- name: Clone aardvark_dns github repository
git:
repo: "{{ podman_aardvark_dns_repopath }}"
dest: "{{ podman_aardvark_dns_buildpath }}"
clone: yes
update: yes
version: "{{ podman_aardvark_dns_version }}"
- name: Build 'all' target with extra arguments
make:
chdir: "{{ podman_aardvark_dns_buildpath }}"
target: "all"
- name: "Create podman folder"
file:
path: "/usr/libexec/podman"
state: directory
mode: 'u=rwx,g=rx,o='
- name: Copy aardvark-dns file
ansible.builtin.copy:
src: "{{ podman_aardvark_dns_buildpath }}/bin/aardvark-dns"
dest: "/usr/libexec/podman/aardvark-dns"
force: true
remote_src: true

18
tasks/install_conmon.yml Normal file
View File

@ -0,0 +1,18 @@
- name: Clone Conmon github repository
git:
repo: "{{ podman_conmon_repopath }}"
dest: "{{ podman_conmon_buildpath }}"
clone: yes
update: yes
version: "{{ podman_conmon_version }}"
- name: Build 'all' target with extra arguments
make:
chdir: "{{ podman_conmon_buildpath }}"
target: "all"
- name: Build 'podman' target with extra arguments
make:
chdir: "{{ podman_conmon_buildpath }}"
target: "podman"

27
tasks/install_crun.yml Normal file
View File

@ -0,0 +1,27 @@
- name: Clone crun github repository
git:
repo: "{{ podman_crun_repopath }}"
dest: "{{ podman_crun_buildpath }}"
clone: yes
update: yes
version: "{{ podman_crun_version }}"
- name: Execute autogen.sh
shell:
cmd: "./autogen.sh"
chdir: "{{ podman_crun_buildpath }}"
- name: Execute autogen.sh
shell:
cmd: "./configure"
chdir: "{{ podman_crun_buildpath }}"
- name: Build 'all' target with extra arguments
make:
chdir: "{{ podman_crun_buildpath }}"
target: "all"
- name: Build 'install' target with extra arguments
make:
chdir: "{{ podman_crun_buildpath }}"
target: "install"

28
tasks/install_depens.yml Normal file
View File

@ -0,0 +1,28 @@
---
- block:
- name: Update apt cache
apt:
cache_valid_time: 3600
update_cache: true
register: _pre_update_apt_cache
until: _pre_update_apt_cache is succeeded
when:
- ansible_pkg_mgr == "apt"
- name: Install dependencies for podman
package:
name: "{{ podman_build_deps }}"
state: present
register: _install_dep_packages
until: _install_dep_packages is succeeded
retries: 5
delay: 2
- name: Install dependencies for crun
package:
name: "{{ crun_build_deps }}"
state: present
register: _install_dep_packages
until: _install_dep_packages is succeeded
retries: 5
delay: 2

View File

@ -0,0 +1,28 @@
- name: Clone netavark github repository
git:
repo: "{{ podman_netavark_repopath }}"
dest: "{{ podman_netavark_buildpath }}"
clone: yes
update: yes
version: "{{ podman_netavark_version }}"
- name: Build 'all' target with extra arguments
make:
chdir: "{{ podman_netavark_buildpath }}"
target: "all"
params:
NUM_THREADS: 4
BACKEND: lapack
- name: "Create podman folder"
file:
path: "/usr/libexec/podman"
state: directory
mode: 'u=rwx,g=rx,o='
- name: Copy netavark file
ansible.builtin.copy:
src: "{{ podman_netavark_buildpath }}/bin/netavark"
dest: "/usr/libexec/podman/netavark"
force: true
remote_src: true

31
tasks/install_podman.yml Normal file
View File

@ -0,0 +1,31 @@
- name: Clone podman github repository
git:
repo: "{{ podman_podman_repopath }}"
dest: "{{ podman_podman_buildpath }}"
clone: yes
update: yes
version: "{{ podman_version }}"
- name: Build 'all' target with extra arguments
make:
chdir: "{{ podman_podman_buildpath }}"
target: "all"
params:
BUILDTAGS: "systemd seccomp"
- name: Build 'install' target with extra arguments
make:
chdir: "{{ podman_podman_buildpath }}"
target: install
params:
PREFIX: "/usr"
- name: Setup systemd service
ansible.builtin.template:
src: podman-docker.service
dest: /lib/systemd/system/podman-docker.service
owner: root
group: root
mode: 0644
notify:
- "Reload systemd"

7
tasks/main.yml Normal file
View File

@ -0,0 +1,7 @@
---
- name: Gather variables for each operating system
include_vars: "{{ ansible_distribution | lower }}.yml"
- include_tasks: install.yml
- include_tasks: configure.yml

View File

@ -0,0 +1,12 @@
[Unit]
Description=Create a symlink for the podman.sock to be used as docker.sock
Documentation=man:podman-start(1)
StartLimitIntervalSec=0
[Service]
Type=oneshot
Environment=LOGGING="--log-level=info"
ExecStart=ln -s /run/podman/podman.sock /run/docker.sock
[Install]
WantedBy=multi-user.target

16
templates/policy.json Normal file
View File

@ -0,0 +1,16 @@
{
"default": [
{
"type": "insecureAcceptAnything"
}
],
"transports": {
"docker-daemon": {
"": [
{
"type": "insecureAcceptAnything"
}
]
}
}
}

79
templates/registries.conf Normal file
View File

@ -0,0 +1,79 @@
# For more information on this configuration file, see containers-registries.conf(5).
#
# NOTE: RISK OF USING UNQUALIFIED IMAGE NAMES
# We recommend always using fully qualified image names including the registry
# server (full dns name), namespace, image name, and tag
# (e.g., registry.redhat.io/ubi8/ubi:latest). Pulling by digest (i.e.,
# quay.io/repository/name@digest) further eliminates the ambiguity of tags.
# When using short names, there is always an inherent risk that the image being
# pulled could be spoofed. For example, a user wants to pull an image named
# `foobar` from a registry and expects it to come from myregistry.com. If
# myregistry.com is not first in the search list, an attacker could place a
# different `foobar` image at a registry earlier in the search list. The user
# would accidentally pull and run the attacker's image and code rather than the
# intended content. We recommend only adding registries which are completely
# trusted (i.e., registries which don't allow unknown or anonymous users to
# create accounts with arbitrary names). This will prevent an image from being
# spoofed, squatted or otherwise made insecure. If it is necessary to use one
# of these registries, it should be added at the end of the list.
#
# # An array of host[:port] registries to try when pulling an unqualified image, in order.
unqualified-search-registries = ["docker.io", "quay.io"]
#
# [[registry]]
# # The "prefix" field is used to choose the relevant [[registry]] TOML table;
# # (only) the TOML table with the longest match for the input image name
# # (taking into account namespace/repo/tag/digest separators) is used.
# #
# # The prefix can also be of the form: *.example.com for wildcard subdomain
# # matching.
# #
# # If the prefix field is missing, it defaults to be the same as the "location" field.
# prefix = "example.com/foo"
#
# # If true, unencrypted HTTP as well as TLS connections with untrusted
# # certificates are allowed.
# insecure = false
#
# # If true, pulling images with matching names is forbidden.
# blocked = false
#
# # The physical location of the "prefix"-rooted namespace.
# #
# # By default, this is equal to "prefix" (in which case "prefix" can be omitted
# # and the [[registry]] TOML table can only specify "location").
# #
# # Example: Given
# # prefix = "example.com/foo"
# # location = "internal-registry-for-example.net/bar"
# # requests for the image example.com/foo/myimage:latest will actually work with the
# # internal-registry-for-example.net/bar/myimage:latest image.
#
# # The location can be empty iff prefix is in a
# # wildcarded format: "*.example.com". In this case, the input reference will
# # be used as-is without any rewrite.
# location = internal-registry-for-example.com/bar"
#
# # (Possibly-partial) mirrors for the "prefix"-rooted namespace.
# #
# # The mirrors are attempted in the specified order; the first one that can be
# # contacted and contains the image will be used (and if none of the mirrors contains the image,
# # the primary location specified by the "registry.location" field, or using the unmodified
# # user-specified reference, is tried last).
# #
# # Each TOML table in the "mirror" array can contain the following fields, with the same semantics
# # as if specified in the [[registry]] TOML table directly:
# # - location
# # - insecure
# [[registry.mirror]]
# location = "example-mirror-0.local/mirror-for-foo"
# [[registry.mirror]]
# location = "example-mirror-1.local/mirrors/foo"
# insecure = true
# # Given the above, a pull of example.com/foo/image:latest will try:
# # 1. example-mirror-0.local/mirror-for-foo/image:latest
# # 2. example-mirror-1.local/mirrors/foo/image:latest
# # 3. internal-registry-for-example.net/bar/image:latest
# # in order, and use the first one that exists.
short-name-mode="permissive"

View File

@ -0,0 +1,46 @@
[aliases]
# centos
"centos" = "registry.centos.org/centos"
# containers
"skopeo" = "quay.io/skopeo/stable"
"buildah" = "quay.io/buildah/stable"
"podman" = "quay.io/podman/stable"
# docker
"alpine" = "docker.io/library/alpine"
"docker" = "docker.io/library/docker"
"registry" = "docker.io/library/registry"
"hello-world" = "docker.io/library/hello-world"
"swarm" = "docker.io/library/swarm"
# Fedora
"fedora-minimal" = "registry.fedoraproject.org/fedora-minimal"
"fedora" = "registry.fedoraproject.org/fedora"
# openSUSE
"opensuse/tumbleweed" = "registry.opensuse.org/opensuse/tumbleweed"
"opensuse/leap" = "registry.opensuse.org/opensuse/leap"
"opensuse/busybox" = "registry.opensuse.org/opensuse/busybox"
"tumbleweed" = "registry.opensuse.org/opensuse/tumbleweed"
"leap" = "registry.opensuse.org/opensuse/leap"
"tw-busybox" = "registry.opensuse.org/opensuse/busybox"
# SUSE
"suse/sle15" = "registry.suse.com/suse/sle15"
"suse/sles12sp5" = "registry.suse.com/suse/sles12sp5"
"suse/sles12sp4" = "registry.suse.com/suse/sles12sp4"
"suse/sles12sp3" = "registry.suse.com/suse/sles12sp3"
"sle15" = "registry.suse.com/suse/sle15"
"sles12sp5" = "registry.suse.com/suse/sles12sp5"
"sles12sp4" = "registry.suse.com/suse/sles12sp4"
"sles12sp3" = "registry.suse.com/suse/sles12sp3"
# Red Hat Enterprise Linux
"rhel" = "registry.access.redhat.com/rhel"
"rhel6" = "registry.access.redhat.com/rhel6"
"rhel7" = "registry.access.redhat.com/rhel7"
"ubi7" = "registry.access.redhat.com/ubi7"
"ubi7-init" = "registry.access.redhat.com/ubi7-init"
"ubi7-minimal" = "registry.access.redhat.com/ubi7-minimal"
"ubi8" = "registry.access.redhat.com/ubi8"
"ubi8-minimal" = "registry.access.redhat.com/ubi8-minimal"
"ubi8-init" = "registry.access.redhat.com/ubi8-init"
# Debian
"debian" = "docker.io/library/debian"
# Ubuntu
"ubuntu" = "docker.io/library/ubuntu"

2
tests/inventory Normal file
View File

@ -0,0 +1,2 @@
192.168.1.142

5
tests/test.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: all
remote_user: root
roles:
- role-podman

35
vars/debian.yml Normal file
View File

@ -0,0 +1,35 @@
---
podman_build_deps:
- make
- gcc
- git
- pkg-config
- btrfs-progs
- go-md2man
#- iptables
- libassuan-dev
- libbtrfs-dev
- libc6-dev
- libdevmapper-dev
- libglib2.0-dev
- libgpgme-dev
- libgpg-error-dev
- libprotobuf-dev
- libprotobuf-c-dev
- libseccomp-dev
- libsystemd-dev
- uidmap
- libselinux1-dev
- libapparmor-dev
- protobuf-compiler
crun_build_deps:
- build-essential
- pkgconf
- libtool
- libcap-dev
- libyajl-dev
- libtool
- autoconf
- python3
- automake

32
vars/fedora.yml Normal file
View File

@ -0,0 +1,32 @@
---
podman_build_deps:
- make
- gcc
- git
- pkg-config
- btrfs-progs
- go-md2man
- iptables
- libassuan-dev
- libbtrfs-dev
- libc6-dev
- libdevmapper-dev
- libglib2.0-dev
- libgpgme-dev
- libgpg-error-dev
- libprotobuf-dev
- libprotobuf-c-dev
- libseccomp-dev
- libsystemd-dev
- uidmap
- golang-github-containers-common
- golang-github-containers-image
- build-essential
- pkgconf
- libtool
- libcap-dev
- libyajl-dev
- libtool
- autoconf
- python3
- automake

1
vars/main.yml Normal file
View File

@ -0,0 +1 @@
---