summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2021-05-19 10:15:25 +0200
committerJonathan Bauer2021-05-19 10:15:25 +0200
commita75da5cd084f71862073ad5707767b6acaba1846 (patch)
treeaf1388517639316e6384f71f858a58a883d1e6ec
parent[cleanup-*] cleanup roles for apt and systemd (diff)
downloadansible-bwlp-a75da5cd084f71862073ad5707767b6acaba1846.tar.gz
ansible-bwlp-a75da5cd084f71862073ad5707767b6acaba1846.tar.xz
ansible-bwlp-a75da5cd084f71862073ad5707767b6acaba1846.zip
[dummy-package] equivs based roled to install dummy packages
-rw-r--r--dummy-package/scripts/dummy-package.sh28
-rw-r--r--dummy-package/tasks/main.yml41
2 files changed, 69 insertions, 0 deletions
diff --git a/dummy-package/scripts/dummy-package.sh b/dummy-package/scripts/dummy-package.sh
new file mode 100644
index 0000000..7990de9
--- /dev/null
+++ b/dummy-package/scripts/dummy-package.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+[ "$#" -eq 2 ] || exit 1
+[ -d "$1" ] || exit 2
+[ -f "$2" ] && rm -f "$2"
+
+cd "$1"
+
+equivs-control "$2"
+
+sed -r -i \
+ -e "s/^(#\s)?(Maintainer).*/\\2: bwlehrpool@hs-offenburg.de/" \
+ -e "s/^(#\s)?(Package).*/\\2: ${2}/" \
+ -e "s/^(#\s)?(Provides).*/\\2: ${2}/" \
+ -e "s/^(#\s)?(Version).*/\\2: 99.9.9/" \
+ -e "s/^(#\s)?(Description).*/\\2: Dummy package to provide $2/" \
+ -e "/^Description.*/q" \
+ "$2"
+
+cat <<EOF >> "$2"
+ Long description
+ with
+ some
+ more
+ lines...
+EOF
+
+equivs-build "$2"
diff --git a/dummy-package/tasks/main.yml b/dummy-package/tasks/main.yml
new file mode 100644
index 0000000..921e4c6
--- /dev/null
+++ b/dummy-package/tasks/main.yml
@@ -0,0 +1,41 @@
+---
+- name: Create and install dummy package
+ block:
+ - name: Install equivs
+ apt:
+ name: equivs
+ state: present
+ update_cache: yes
+
+ - name: Create temporary directory for packages
+ tempfile:
+ state: directory
+ register: tempdir
+
+ - name: Create dummy packages
+ script: scripts/dummy-package.sh "{{ tempdir.path }}" "{{ item }}"
+ args:
+ executable: bash
+ loop: "{{ dummy_packages }}"
+
+ - name: Register newly created packages
+ find:
+ path: "{{ tempdir.path }}"
+ pattern: '*.deb'
+ register: deb_files
+
+ - name: Install dummy packages
+ apt:
+ deb: "{{ item.path }}"
+ loop: "{{ deb_files.files }}"
+
+ - name: Hold on to dummy packages
+ command: "apt-mark hold {{ item }}"
+ loop: "{{ dummy_packages }}"
+
+ - name: Remove temporary directory
+ file:
+ path: "${{ tempdir.path }}"
+ state: absent
+ when:
+ - dummy_packages is defined