[__apt_key] fails on dry-run #6

Open
opened 2021-11-20 11:24:44 +00:00 by ungleich-gitea · 0 comments
$ echo '__apt_key foo --uri https://updates.signal.org/desktop/apt/keys.asc' | cdist config -i - localhost -n
INFO: [131777]: localhost: Starting dry run
INFO: [132181]: localhost: Processing __download/etc/apt/trusted.gpg.d/foo.gpg.cdist
ERROR: [131777]: localhost: /home/ander/Desktop/src/cdist/cdist/conf/type/__file/gencode-local: ['/home/ander/Desktop/src/cdist/cdist/conf/type/__file/gencode-local']

Error processing object '__file/etc/apt/trusted.gpg.d/foo.gpg'
==============================================================
name: __file/etc/apt/trusted.gpg.d/foo.gpg
path: /tmp/tmpvffcrfse/421aa90e079fa326b6494f812ad13e79/data/object/__file/etc/apt/trusted.gpg.d/foo.gpg/.cdist-x1915kym
source: /tmp/tmpvffcrfse/421aa90e079fa326b6494f812ad13e79/data/conf/type/__apt_key/manifest
type: /home/ander/Desktop/src/cdist/cdist/conf/type/__file

gencode-local:stderr
--------------------
File "/etc/apt/trusted.gpg.d/foo.gpg" does not exist

how I patched it:

diff --git a/cdist/conf/type/__apt_key/manifest b/cdist/conf/type/__apt_key/manifest
index 889a764a..241ba02b 100755
--- a/cdist/conf/type/__apt_key/manifest
+++ b/cdist/conf/type/__apt_key/manifest
@@ -96,7 +96,7 @@ elif [ "${method}" = "source" ] || [ "${method}" = "uri" ]; then
                        __file "${keyfile}" \
                                --owner root \
                                --mode 0444 \
-                               --state pre-exists
+                               --state "$( if [ -n "$__cdist_dry_run" ]; then echo 'present'; else echo 'pre-exists'; fi )"
        else
                __file "${keyfilecdist}" --state "${state_should}" \
                        --mode 0444 \

and after that it works as expected:

$ echo '__apt_key foo --uri https://updates.signal.org/desktop/apt/keys.asc' | cdist config -i - localhost -n
INFO: [133521]: localhost: Starting dry run
INFO: [133925]: localhost: Processing __download/etc/apt/trusted.gpg.d/foo.gpg.cdist
INFO: [133521]: localhost: Processing __file/etc/apt/trusted.gpg.d/foo.gpg
INFO: [133521]: localhost: Finished dry run in 1.51 seconds

@evilham maybe you have some better ideas how to fix this?

also, why we need that .cdist file there?

```bash $ echo '__apt_key foo --uri https://updates.signal.org/desktop/apt/keys.asc' | cdist config -i - localhost -n INFO: [131777]: localhost: Starting dry run INFO: [132181]: localhost: Processing __download/etc/apt/trusted.gpg.d/foo.gpg.cdist ERROR: [131777]: localhost: /home/ander/Desktop/src/cdist/cdist/conf/type/__file/gencode-local: ['/home/ander/Desktop/src/cdist/cdist/conf/type/__file/gencode-local'] Error processing object '__file/etc/apt/trusted.gpg.d/foo.gpg' ============================================================== name: __file/etc/apt/trusted.gpg.d/foo.gpg path: /tmp/tmpvffcrfse/421aa90e079fa326b6494f812ad13e79/data/object/__file/etc/apt/trusted.gpg.d/foo.gpg/.cdist-x1915kym source: /tmp/tmpvffcrfse/421aa90e079fa326b6494f812ad13e79/data/conf/type/__apt_key/manifest type: /home/ander/Desktop/src/cdist/cdist/conf/type/__file gencode-local:stderr -------------------- File "/etc/apt/trusted.gpg.d/foo.gpg" does not exist ``` how I patched it: ```diff diff --git a/cdist/conf/type/__apt_key/manifest b/cdist/conf/type/__apt_key/manifest index 889a764a..241ba02b 100755 --- a/cdist/conf/type/__apt_key/manifest +++ b/cdist/conf/type/__apt_key/manifest @@ -96,7 +96,7 @@ elif [ "${method}" = "source" ] || [ "${method}" = "uri" ]; then __file "${keyfile}" \ --owner root \ --mode 0444 \ - --state pre-exists + --state "$( if [ -n "$__cdist_dry_run" ]; then echo 'present'; else echo 'pre-exists'; fi )" else __file "${keyfilecdist}" --state "${state_should}" \ --mode 0444 \ ``` and after that it works as expected: ```bash $ echo '__apt_key foo --uri https://updates.signal.org/desktop/apt/keys.asc' | cdist config -i - localhost -n INFO: [133521]: localhost: Starting dry run INFO: [133925]: localhost: Processing __download/etc/apt/trusted.gpg.d/foo.gpg.cdist INFO: [133521]: localhost: Processing __file/etc/apt/trusted.gpg.d/foo.gpg INFO: [133521]: localhost: Finished dry run in 1.51 seconds ``` @evilham maybe you have some better ideas how to fix this? also, why we need that `.cdist` file there?
evilham was assigned by ungleich-gitea 2021-11-20 11:24:44 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#6
No description provided.