Vendor Galaxy Roles and Collections

This commit is contained in:
Stefan Bethke 2026-02-06 22:07:16 +01:00
commit 2aed20393f
496 changed files with 387444 additions and 2 deletions

View file

@ -0,0 +1,9 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# See template for more information:
# https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/config/config.yml
modules:
python_requires: default

View file

@ -0,0 +1,20 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- hosts: localhost
vars:
docker_test_image_alpine: quay.io/ansible/docker-test-containers:alpine3.8
tasks:
- name: Find all roles
ansible.builtin.find:
paths:
- "{{ (playbook_dir | default('.')) ~ '/roles' }}"
file_type: directory
depth: 1
register: result
- name: Include all roles
ansible.builtin.include_role:
name: "{{ item }}"
loop: "{{ result.files | map(attribute='path') | map('regex_replace', '.*/', '') | sort }}"

View file

@ -0,0 +1,34 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Retrieve information on current container
community.docker.current_container_facts:
register: result
# The following two tasks are useful if we ever have to debug why this fails.
- name: Print all Ansible facts
ansible.builtin.debug:
var: ansible_facts
- name: Read some files
ansible.builtin.slurp:
src: "{{ path }}"
loop:
- /proc/self/cpuset
- /proc/1/cgroup
- /proc/1/environ
loop_control:
loop_var: path
- name: Print facts returned by module
ansible.builtin.debug:
var: result.ansible_facts
- name: Validate results
ansible.builtin.assert:
that:
- ansible_module_running_in_container
- ansible_module_container_type != ''

View file

@ -0,0 +1,32 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# Create random name prefix (for containers, networks, ...)
- name: Create random container name prefix
ansible.builtin.set_fact:
cname_prefix: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Make sure image is absent
community.docker.docker_image:
name: "{{ docker_test_image_alpine }}"
state: absent
- name: Make sure image is pulled
community.docker.docker_image:
name: "{{ docker_test_image_alpine }}"
source: pull
- name: Start container
community.docker.docker_container:
name: "{{ cname_prefix }}-1"
image: "{{ docker_test_image_alpine }}"
state: started
- name: Remove container
community.docker.docker_container:
name: "{{ cname_prefix }}-1"
state: absent
stop_timeout: 1
force_kill: true

View file

@ -0,0 +1,6 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# Currently the docker_stack* modules are not supported in the EE since we'd need to install the Docker CLI client

View file

@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
if [ ! -e main.go ]; then
echo "Must be run in a directory that contains main.go."
exit 1
fi
set -eux
IMAGE_NAME="${1:-localhost/$(basename "$(pwd)"):latest}"
podman manifest rm "${IMAGE_NAME}" || true
podman image rm "${IMAGE_NAME}" || true
buildah manifest create "${IMAGE_NAME}"
for ARCH in amd64 arm64 386; do
rm -f "main-${ARCH}"
GOARCH="${ARCH}" go build -ldflags "-s -w" -o "main-${ARCH}" main.go
WORKING_CONTAINER="$(buildah from --arch "${ARCH}" scratch)"
buildah copy "${WORKING_CONTAINER}" "main-${ARCH}" "/runme"
buildah config --entrypoint '["/runme"]' "${WORKING_CONTAINER}"
buildah commit --manifest "${IMAGE_NAME}" "${WORKING_CONTAINER}"
rm -f "main-${ARCH}"
done

View file

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
set -e
# Uncomment the container image to copy, and run this script to copy it.
DESTINATION_REPO=ansible-collections/community.docker
function convert_image {
echo "========================================================================================================="
local IMAGE_NAME="$1"
local DEST_IMAGE="$2"
echo "FROM ${IMAGE_NAME}" | podman build --annotation "org.opencontainers.image.source=https://github.com/${DESTINATION_REPO}" -t "ghcr.io/${DESTINATION_REPO}/${DEST_IMAGE}" -
podman push "ghcr.io/${DESTINATION_REPO}/${DEST_IMAGE}"
podman rmi "${IMAGE_NAME}"
podman rmi "ghcr.io/${DESTINATION_REPO}/${DEST_IMAGE}"
}
# convert_image docker.io/library/registry:2.6.1 docker-distribution:2.6.1
# convert_image docker.io/library/registry:2.8.3 docker-distribution:2.8.3
# convert_image docker.io/library/registry:3.0.0 docker-distribution:3.0.0
convert_image docker.io/library/python:3-alpine docker-python:3-alpine

View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
if [ ! -e main.go ]; then
echo "Must be run in a directory that contains main.go."
exit 1
fi
PROGRAMS="main is-healthy make-healthy"
set -eux
IMAGE_NAME="${1:-localhost/$(basename "$(pwd)"):latest}"
podman manifest rm "${IMAGE_NAME}" || true
podman image rm "${IMAGE_NAME}" || true
buildah manifest create "${IMAGE_NAME}"
for ARCH in amd64 arm64 386; do
for PROGRAM in ${PROGRAMS}; do
rm -f "${PROGRAM}-${ARCH}"
GOARCH="${ARCH}" go build -ldflags "-s -w" -o "${PROGRAM}-${ARCH}" "${PROGRAM}.go"
done
# Need format=docker for health checks to work
WORKING_CONTAINER="$(buildah from --arch "${ARCH}" --format docker scratch)"
for PROGRAM in ${PROGRAMS}; do
buildah copy "${WORKING_CONTAINER}" "${PROGRAM}-${ARCH}" "/${PROGRAM}"
done
buildah config --entrypoint '["/main"]' "${WORKING_CONTAINER}"
buildah config --healthcheck 'CMD /is-healthy' "${WORKING_CONTAINER}"
buildah config --healthcheck-interval 1s "${WORKING_CONTAINER}"
buildah config --healthcheck-retries 1 "${WORKING_CONTAINER}"
buildah config --healthcheck-start-period 10s "${WORKING_CONTAINER}"
buildah commit --format docker --manifest "${IMAGE_NAME}" "${WORKING_CONTAINER}"
for PROGRAM in ${PROGRAMS}; do
rm -f "${PROGRAM}-${ARCH}"
done
done

View file

@ -0,0 +1,35 @@
/*
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
*/
package main
import (
"bytes"
"fmt"
"os"
)
func main() {
data, err := os.ReadFile("/health.txt")
if err != nil {
fmt.Fprintf(os.Stderr, "Error while reading health status: %s\n", err)
os.Exit(1)
}
if bytes.Equal(data, []byte("healthy")) {
fmt.Fprintf(os.Stdout, "Healthy.\n")
os.Exit(0)
}
if bytes.Equal(data, []byte("unhealthy")) {
fmt.Fprintf(os.Stdout, "Unhealthy!\n")
os.Exit(1)
}
if bytes.Equal(data, []byte("starting")) {
fmt.Fprintf(os.Stdout, "Starting...\n")
os.Exit(1)
}
fmt.Fprintf(os.Stderr, "Unknown health status: %s\n", data)
os.Exit(1)
}

View file

@ -0,0 +1,51 @@
/*
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
*/
package main
import (
"fmt"
"os"
"time"
)
func main() {
os.WriteFile("health.txt", []byte("starting"), 0644)
if len(os.Args) > 3 || len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "%s must have 1 or 2 arguments, not %d arguments\n", os.Args[0], len(os.Args))
os.Exit(1)
}
runtimeDelay, err := time.ParseDuration(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot parse runtime duration: %s\n", err)
os.Exit(1)
}
if runtimeDelay.Microseconds() <= 0 {
fmt.Fprintf(os.Stderr, "Delay must be positive!\n")
os.Exit(1)
}
var healthyDelay time.Duration
if len(os.Args) == 3 {
healthyDelay, err = time.ParseDuration(os.Args[2])
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot parse healthy delay: %s\n", err)
os.Exit(1)
}
if healthyDelay.Microseconds() <= 0 {
fmt.Fprintf(os.Stderr, "Healthy delay must not be negative!\n")
os.Exit(1)
}
}
if healthyDelay.Microseconds() > 0 {
fmt.Fprintf(os.Stderr, "Waiting %s until setting to healthy...\n", healthyDelay)
time.Sleep(healthyDelay)
os.WriteFile("/health.txt", []byte("healthy"), 0644)
fmt.Fprintf(os.Stderr, "Set state to healthy.\n")
}
fmt.Fprintf(os.Stderr, "Waiting %s until quitting...\n", runtimeDelay)
time.Sleep(runtimeDelay)
fmt.Fprintf(os.Stderr, "Goodbye.\n")
}

View file

@ -0,0 +1,35 @@
/*
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
*/
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
healthy := true
if len(os.Args) > 2 {
fmt.Fprintf(os.Stderr, "%s must have 0 or 1 argument, not %d arguments\n", os.Args[0], len(os.Args))
os.Exit(1)
} else if len(os.Args) == 2 {
var err error
healthy, err = strconv.ParseBool(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot parse boolean: %s\n", err)
os.Exit(1)
}
}
var state []byte
if healthy {
state = []byte("healthy")
} else {
state = []byte("unhealthy")
}
os.WriteFile("/health.txt", state, 0644)
}

View file

@ -0,0 +1 @@
../build.sh

View file

@ -0,0 +1,34 @@
/*
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
*/
package main
import (
"fmt"
"os"
"time"
)
func main() {
var delay time.Duration
if len(os.Args) > 2 {
fmt.Fprintf(os.Stderr, "%s must have 0 or 1 argument, not %d arguments\n", os.Args[0], len(os.Args))
os.Exit(1)
} else if len(os.Args) == 2 {
var err error
delay, err = time.ParseDuration(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot parse delay duration: %s\n", err)
os.Exit(1)
}
if delay.Microseconds() < 0 {
fmt.Fprintf(os.Stderr, "Delay must not be negative!\n")
os.Exit(1)
}
}
fmt.Println("Hello!")
time.Sleep(delay)
}

View file

@ -0,0 +1 @@
../build.sh

View file

@ -0,0 +1,34 @@
/*
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
*/
package main
import (
"fmt"
"os"
"time"
)
func main() {
var delay time.Duration
if len(os.Args) > 2 {
fmt.Fprintf(os.Stderr, "%s must have 0 or 1 argument, not %d arguments\n", os.Args[0], len(os.Args))
os.Exit(1)
} else if len(os.Args) == 2 {
var err error
delay, err = time.ParseDuration(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot parse delay duration: %s\n", err)
os.Exit(1)
}
if delay.Microseconds() < 0 {
fmt.Fprintf(os.Stderr, "Delay must not be negative!\n")
os.Exit(1)
}
}
fmt.Println("World!")
time.Sleep(delay)
}

View file

@ -0,0 +1,11 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
collections:
- ansible.posix
- community.crypto
- community.general
- community.internal_test_tools
- community.library_inventory_filtering_v1

View file

@ -0,0 +1,5 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
hidden

View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
set -eux
[ -f "${INVENTORY}" ]
# Run connection tests with both the default and C locale.
ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
if ansible --version | grep ansible | grep -E ' 2\.(9|10|11|12|13)\.'; then
LC_ALL=C LANG=C ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
fi

View file

@ -0,0 +1,48 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- hosts: "{{ target_hosts }}" # noqa: syntax-check[specific]
gather_facts: false
serial: 1
tasks:
### raw with unicode arg and output
- name: raw with unicode arg and output
raw: echo 汉语
register: command
- name: check output of raw with unicode arg and output
assert:
that:
- "'汉语' in command.stdout"
- command is changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules
### copy local file with unicode filename and content
- name: create local file with unicode filename and content
local_action: lineinfile dest={{ local_tmp }}-汉语/汉语.txt create=true line=汉语
- name: remove remote file with unicode filename and content
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语/汉语.txt state=absent"
- name: create remote directory with unicode name
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=directory"
- name: copy local file with unicode filename and content
action: "{{ action_prefix }}copy src={{ local_tmp }}-汉语/汉语.txt dest={{ remote_tmp }}-汉语/汉语.txt"
### fetch remote file with unicode filename and content
- name: remove local file with unicode filename and content
local_action: file path={{ local_tmp }}-汉语/汉语.txt state=absent
- name: fetch remote file with unicode filename and content
fetch: src={{ remote_tmp }}-汉语/汉语.txt dest={{ local_tmp }}-汉语/汉语.txt fail_on_missing=true validate_checksum=true flat=true
### remove local and remote temp files
- name: remove local temp file
local_action: file path={{ local_tmp }}-汉语 state=absent
- name: remove remote temp file
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=absent"
### test wait_for_connection plugin
- ansible.builtin.wait_for_connection:

View file

@ -0,0 +1,7 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
azp/4
skip/docker # coverage does not work if we're inside a docker container, since we cannot access this container's /tmp dir from the new container; also privileged doesn't work
destructive

Some files were not shown because too many files have changed in this diff Show more