diff --git a/tasks/config/hashicorp.yml b/tasks/config/hashicorp.yml index fb4bf55..0b39e4e 100644 --- a/tasks/config/hashicorp.yml +++ b/tasks/config/hashicorp.yml @@ -1,13 +1,13 @@ - name: Set OS name for RedHat family when: - - ansible_os_famly == 'RedHat' + - ansible_os_family == 'RedHat' ansible.builtin.set_fact: hashicorp: - repo: "{{ pkgconfig.hashicorp.Linux[rpm_dist.stdout] }}" + repo: "{{ pkgconfig.hashicorp.Linux[rpm_dist.stdout].repo }}" - name: Set repo for debian when: - ansible_os_family == 'Debian' ansible.builtin.set_Fact: hashicorp: - repo: "{{ pkgconfig.hashicorp.Linux.Debian }}" + repo: "{{ pkgconfig.hashicorp.Linux.Debian.repo }}" diff --git a/tasks/config/zfs.yml b/tasks/config/zfs.yml index 0b124d0..88925b3 100644 --- a/tasks/config/zfs.yml +++ b/tasks/config/zfs.yml @@ -5,11 +5,16 @@ ansible.builtin.set_fact: rhname: "{%if ansible_distribution == 'Fedora' %}fedora{% else %}epel{% endif %}" +- name: Set deps for distros + ansible.builtin.set_fact: + zfs: + deps: "{% if ansible_distribution == 'Fedora' %}{{ pkgconfig.zfs.build_deps.Fedora }}{% else %}{{ pkgconfig.zfs.build_deps[ansible_os_family] }}{% endif %}" + - name: Set ZFS config ansible.builtin.set_fact: zfs: repo_pkg: "{{ pkgconfig.zfs.repo_base }}/{{ rhname }}/zfs-release-{{ pkgconfig.zfs[rhname].release }}{{ rpm_dist.stdout }}.noarch.rpm" - deps: "{{ pkgconfig.zfs.build_deps[ansible_os_family] }}" + deps: "{{ zfs.deps }}" pkgs: "{{ pkgconfig.zfs.pkgs[ansible_os_family] }}" skip_gpg_check: "{{ rhname == 'fedora' }}" release: "{{ ansible_distribution_release }}" diff --git a/tasks/repos/hashicorp.yml b/tasks/repos/hashicorp.yml index 9f57bc6..9962b96 100644 --- a/tasks/repos/hashicorp.yml +++ b/tasks/repos/hashicorp.yml @@ -8,31 +8,12 @@ when: - ansible_os_family == 'RedHat' block: - - name: Enable hashicorp repo for fedora >=41 + - name: Enable hashicorp repo become: true - when: - - ansible_distribution == 'Fedora' - - ansible_distribution_major_version|int >= 41 - ansible.builtin.command: - creates: /etc/yum.repos.d/hashicorp.repo - cmd: "dnf config-manager addrepo --from-repofile={{ hashicorp.repo }}" - - - name: Enable hashicorp repo for fedora <41 - become: true - when: - - ansible_distribution == 'Fedora' - - ansible_distribution_major_version|int < 41 - ansible.builtin.command: - creates: /etc/yum.repos.d/hashicorp.repo - cmd: "dnf config-manager --add-repo {{ hashicorp.repo }}" - - - name: Enable hashicorp repo for RHEL like distribution - become: true - when: - - ansible_distribution != 'Fedora' - ansible.builtin.command: - creates: /etc/yum.repos.d/hashicorp.repo - cmd: "dnf config-manager --add-repo {{ hashicorp.repo }}" + ansible.builtin.get_url: + url: "{{ hashicorp.repo }}" + dest: /etc/yum.repos.d/hashicorp.repo + mode: '0644' - name: Debian based repository when: diff --git a/tests/Containerfile.debian b/tests/Containerfile.debian new file mode 100644 index 0000000..67ca74f --- /dev/null +++ b/tests/Containerfile.debian @@ -0,0 +1,18 @@ +FROM debian:bookworm +LABEL PROJECT "ansible_role_package" +LABEL MAINTAINER "Matthew Stobbs " + +RUN useradd -d /home/ansible -m -G wheel ansible +RUN apt update && \ + apt install -y openssh-server python3-paramiko gnupg2 +EXPOSE 22 + +USER ansible +WORKDIR /home/ansible +RUN mkdir /home/ansible/.ssh +COPY ./pubkey /home/ansible/.ssh/authorized_keys + +USER root +RUN echo "ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/sudoers +RUN ssh-keygen -A +ENTRYPOINT /usr/sbin/sshd -D diff --git a/tests/Containerfile.el9 b/tests/Containerfile.el9 new file mode 100644 index 0000000..15f4d96 --- /dev/null +++ b/tests/Containerfile.el9 @@ -0,0 +1,17 @@ +FROM almalinux:9 +LABEL PROJECT "ansible_role_package" +LABEL MAINTAINER "Matthew Stobbs " + +RUN useradd -d /home/ansible -m -G wheel ansible +RUN dnf install -y openssh-server python3-paramiko python3-libdnf gnupg2 +EXPOSE 22 + +USER ansible +WORKDIR /home/ansible +RUN mkdir /home/ansible/.ssh +COPY ./pubkey /home/ansible/.ssh/authorized_keys + +USER root +RUN echo "ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/sudoers +RUN ssh-keygen -A +ENTRYPOINT /usr/sbin/sshd -D diff --git a/tests/Containerfile b/tests/Containerfile.fedora similarity index 100% rename from tests/Containerfile rename to tests/Containerfile.fedora diff --git a/tests/Containerfile.ubuntu b/tests/Containerfile.ubuntu new file mode 100644 index 0000000..334297c --- /dev/null +++ b/tests/Containerfile.ubuntu @@ -0,0 +1,18 @@ +FROM ubuntu:24.04 +LABEL PROJECT "ansible_role_package" +LABEL MAINTAINER "Matthew Stobbs " + +RUN useradd -d /home/ansible -m -G wheel ansible +RUN apt update && \ + apt install -y openssh-server python3-paramiko gnupg2 +EXPOSE 22 + +USER ansible +WORKDIR /home/ansible +RUN mkdir /home/ansible/.ssh +COPY ./pubkey /home/ansible/.ssh/authorized_keys + +USER root +RUN echo "ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/sudoers +RUN ssh-keygen -A +ENTRYPOINT /usr/sbin/sshd -D diff --git a/tests/setup.sh b/tests/setup.sh index 8c2572d..ea8418e 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -20,4 +20,7 @@ done echo "Machine $MACHINENAME running" echo "Building container images" -podman build --platform linux/amd64 -f Containerfile -t $IMAGE . +podman build --platform linux/amd64 -f Containerfile.el9 -t ${IMAGE}_el9 . +podman build --platform linux/amd64 -f Containerfile.fedora -t ${IMAGE)_fedora . +podman build --platform linux/amd64 -f Containerfile.debian -t ${IMAGE}_debian . +podman build --platform linux/amd64 -f Containerfile.ubuntu -t ${IMAGE}_ubuntu . diff --git a/tests/test.sh b/tests/test.sh index be70e82..d669072 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -3,3 +3,12 @@ podman run --rm -it -d --platform linux/amd64 --name packagetest -p 2222:22 packagetest ansible-playbook test_not_local.yml -i inventory.yml podman stop packagetest +podman run --rm -it -d --platform linux/amd64 --name packagetest -p 2222:22 packagetest +ansible-playbook test_not_local.yml -i inventory.yml +podman stop packagetest +podman run --rm -it -d --platform linux/amd64 --name packagetest -p 2222:22 packagetest +ansible-playbook test_not_local.yml -i inventory.yml +podman stop packagetest +podman run --rm -it -d --platform linux/amd64 --name packagetest -p 2222:22 packagetest +ansible-playbook test_not_local.yml -i inventory.yml +podman stop packagetest diff --git a/vars/pkgs/zfs.yml b/vars/pkgs/zfs.yml index ff2138d..d350fe5 100644 --- a/vars/pkgs/zfs.yml +++ b/vars/pkgs/zfs.yml @@ -13,6 +13,8 @@ zfs: - zfs-dkms - zfsutils-linux build_deps: + Fedora: + - kernel-devel RedHat: - kernel-devel - epel-release