]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
share/ansible: create roles
authorIker Pedrosa <ipedrosa@redhat.com>
Tue, 14 May 2024 10:49:28 +0000 (12:49 +0200)
committerSerge Hallyn <serge@hallyn.com>
Thu, 18 Jul 2024 15:17:29 +0000 (10:17 -0500)
Create `build_container` and `ci_run` roles and move the fedora target
to them.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
share/ansible/playbook.yml
share/ansible/roles/build_container/README.md [new file with mode: 0644]
share/ansible/roles/build_container/tasks/main.yml [new file with mode: 0644]
share/ansible/roles/ci_run/README.md [new file with mode: 0644]
share/ansible/roles/ci_run/tasks/main.yml [new file with mode: 0644]

index 2325d9a90e719e394fc744ae1ea96808dc29e345..95a4cb887a727da00cbf0c3a577a8465c57629cc 100644 (file)
@@ -1,89 +1,13 @@
 - name: Start build container
   hosts: localhost
-  tasks:
-    - name: Pull container image
-      containers.podman.podman_image:
-        name: registry.fedoraproject.org/fedora:latest
-
-    - name: Create and start container
-      containers.podman.podman_container:
-        name: builder
-        state: started
-        image: fedora:latest
-        command: "sleep 1d"
-
-    - name: Copy repo
-      ansible.builtin.shell:
-        podman cp ../../ builder:/usr/local/src
+  roles:
+    - role: build_container
+      vars:
+        container_image: registry.fedoraproject.org/fedora:latest
 
 - name: CI run
   hosts: builder
   connection: podman
-  tasks:
-    - name: Ensure dependencies are installed
-      ansible.builtin.dnf:
-        name:
-          - dnf-plugins-core
-          - libcmocka-devel
-          - systemd-devel
-        state: present
-
-    - name: Ensure build dependencies are installed
-      ansible.builtin.command:
-        dnf builddep -y shadow-utils
-      register: dnf_result
-      changed_when: '"Nothing to do" not in dnf_result.stdout'
-
-    - name: Build configuration
-      ansible.builtin.command: >
-        ./autogen.sh
-        --disable-account-tools-setuid
-        --enable-lastlog
-        --enable-logind=no
-        --enable-man
-        --enable-shadowgrp
-        --enable-shared
-        --with-audit
-        --with-bcrypt
-        --with-group-name-max-length=32
-        --with-libpam
-        --with-selinux
-        --with-sha-crypt
-        --with-yescrypt
-        --without-libbsd
-        --without-libcrack
-        --without-sssd
-      args:
-        chdir: /usr/local/src/shadow/
-      ignore_errors: true
-
-    - name: Build
-      ansible.builtin.shell:
-        make -Orecurse -j4 > build.log
-      args:
-        chdir: /usr/local/src/shadow/
-      ignore_errors: true
-
-    - name: Run unit-tests
-      ansible.builtin.command:
-        make check
-      args:
-        chdir: /usr/local/src/shadow/
-      ignore_errors: true
-
-    - name: Install
-      ansible.builtin.command:
-        make install
-      args:
-        chdir: /usr/local/src/shadow/
-      ignore_errors: true
-
-    - name: Copy shadow repo
-      ansible.builtin.fetch:
-        src: '{{ item }}'
-        dest: ./build-out/
-      with_items:
-        - "/usr/local/src/shadow/config.log"
-        - "/usr/local/src/shadow/config.h"
-        - "/usr/local/src/shadow/build.log"
-        - "/usr/local/src/shadow/tests/unit/test-suite.log"
+  gather_facts: false
+  roles:
+    - role: ci_run
diff --git a/share/ansible/roles/build_container/README.md b/share/ansible/roles/build_container/README.md
new file mode 100644 (file)
index 0000000..e55598a
--- /dev/null
@@ -0,0 +1,28 @@
+Role Name
+=========
+
+Build container images.
+
+Role Variables
+--------------
+
+* `image[distribution]` defines the container image URL.
+
+Example Playbook
+----------------
+
+Usage example:
+
+    - hosts: localhost
+      roles:
+        - role: build_container
+
+License
+-------
+
+BSD
+
+Author Information
+------------------
+
+Iker Pedrosa <ipedrosa@redhat.com>
diff --git a/share/ansible/roles/build_container/tasks/main.yml b/share/ansible/roles/build_container/tasks/main.yml
new file mode 100644 (file)
index 0000000..f7d3dbc
--- /dev/null
@@ -0,0 +1,20 @@
+---
+# tasks file for build_container
+- name: Pull container image
+  containers.podman.podman_image:
+    name: '{{ container_image }}'
+
+- name: Create and start container
+  containers.podman.podman_container:
+    name: builder
+    state: started
+    image: '{{ container_image }}'
+    command: "sleep 1d"
+
+- name: Create repo
+  ansible.builtin.shell:
+    podman exec builder mkdir -p /usr/local/src
+
+- name: Copy repo
+  ansible.builtin.shell:
+    podman cp ../../ builder:/usr/local/src/shadow
diff --git a/share/ansible/roles/ci_run/README.md b/share/ansible/roles/ci_run/README.md
new file mode 100644 (file)
index 0000000..bc74f81
--- /dev/null
@@ -0,0 +1,25 @@
+Role Name
+=========
+
+Build, install and test package.
+
+Example Playbook
+----------------
+
+Usage example:
+
+    - hosts: builder
+      connection: podman
+      gather_facts: false
+      roles:
+        - role: ci_run
+
+License
+-------
+
+BSD
+
+Author Information
+------------------
+
+Iker Pedrosa <ipedrosa@redhat.com>
diff --git a/share/ansible/roles/ci_run/tasks/main.yml b/share/ansible/roles/ci_run/tasks/main.yml
new file mode 100644 (file)
index 0000000..c477a83
--- /dev/null
@@ -0,0 +1,69 @@
+---
+# tasks file for ci_run
+- name: Ensure dependencies are installed
+  ansible.builtin.dnf:
+    name:
+      - dnf-plugins-core
+      - libcmocka-devel
+      - systemd-devel
+    state: present
+
+- name: Ensure build dependencies are installed
+  ansible.builtin.command:
+    dnf builddep -y shadow-utils
+  register: dnf_result
+  changed_when: '"Nothing to do" not in dnf_result.stdout'
+
+- name: Build configuration
+  ansible.builtin.command: >
+    ./autogen.sh
+    --disable-account-tools-setuid
+    --enable-lastlog
+    --enable-logind=no
+    --enable-man
+    --enable-shadowgrp
+    --enable-shared
+    --with-audit
+    --with-bcrypt
+    --with-group-name-max-length=32
+    --with-libpam
+    --with-selinux
+    --with-sha-crypt
+    --with-yescrypt
+    --without-libbsd
+    --without-libcrack
+    --without-sssd
+  args:
+    chdir: /usr/local/src/shadow/
+  ignore_errors: true
+
+- name: Build
+  ansible.builtin.shell:
+    make -Orecurse -j4 > build.log
+  args:
+    chdir: /usr/local/src/shadow/
+  ignore_errors: true
+
+- name: Run unit-tests
+  ansible.builtin.command:
+    make check
+  args:
+    chdir: /usr/local/src/shadow/
+  ignore_errors: true
+
+- name: Install
+  ansible.builtin.command:
+    make install
+  args:
+    chdir: /usr/local/src/shadow/
+  ignore_errors: true
+
+- name: Copy shadow repo
+  ansible.builtin.fetch:
+    src: '{{ item }}'
+    dest: ./build-out/
+  with_items:
+    - "/usr/local/src/shadow/config.log"
+    - "/usr/local/src/shadow/config.h"
+    - "/usr/local/src/shadow/build.log"
+    - "/usr/local/src/shadow/tests/unit/test-suite.log"