From e4910933b109c4d0858a0fa6ee901d211544e6e1 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 16 Nov 2012 14:56:20 +0100 Subject: [PATCH] __apt_ppa: /enabled/present/ -e /disabled/absent/ Signed-off-by: Steven Armstrong --- cdist/conf/type/__apt_ppa/explorer/state | 2 +- cdist/conf/type/__apt_ppa/gencode-remote | 20 +++++++++++--------- cdist/conf/type/__apt_ppa/man.text | 6 +++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cdist/conf/type/__apt_ppa/explorer/state b/cdist/conf/type/__apt_ppa/explorer/state index 8a5638b2..2d8ca7c5 100755 --- a/cdist/conf/type/__apt_ppa/explorer/state +++ b/cdist/conf/type/__apt_ppa/explorer/state @@ -29,5 +29,5 @@ repo_name="${name#ppa:}" repo_file_name="$(echo "$repo_name" | sed "s:\/:\-:")-${DISTRIB_CODENAME}.list" [ -s "/etc/apt/sources.list.d/${repo_file_name}" ] \ - && echo enabled || echo disabled + && echo present || echo absent diff --git a/cdist/conf/type/__apt_ppa/gencode-remote b/cdist/conf/type/__apt_ppa/gencode-remote index 0e7fe163..0ea8011c 100755 --- a/cdist/conf/type/__apt_ppa/gencode-remote +++ b/cdist/conf/type/__apt_ppa/gencode-remote @@ -22,14 +22,16 @@ name="$__object_id" state_should="$(cat "$__object/parameter/state")" state_is="$(cat "$__object/explorer/state")" -if [ "$state_should" != "$state_is" ]; then - case "$state_should" in - enabled) - echo add-apt-repository \"$name\" - ;; - disabled) - echo remove-apt-repository \"$name\" - ;; - esac +if [ "$state_should" == "$state_is" ]; then + # Nothing to do, move along + exit 0 fi +case "$state_should" in + present) + echo add-apt-repository \"$name\" + ;; + absent) + echo remove-apt-repository \"$name\" + ;; +esac diff --git a/cdist/conf/type/__apt_ppa/man.text b/cdist/conf/type/__apt_ppa/man.text index f986eb2d..6a5990d5 100644 --- a/cdist/conf/type/__apt_ppa/man.text +++ b/cdist/conf/type/__apt_ppa/man.text @@ -16,7 +16,7 @@ This cdist type allows manage ubuntu ppa repositories. REQUIRED PARAMETERS ------------------- state:: - The state the ppa should be in, either "enabled" or "disabled". + The state the ppa should be in, either "present" or "absent". OPTIONAL PARAMETERS @@ -29,10 +29,10 @@ EXAMPLES -------------------------------------------------------------------------------- # Enable a ppa repository -__apt_ppa ppa:sans-intern/missing-bits --state enabled +__apt_ppa ppa:sans-intern/missing-bits --state present # Disable a ppa repository -__apt_ppa ppa:sans-intern/missing-bits --state disabled +__apt_ppa ppa:sans-intern/missing-bits --state absent --------------------------------------------------------------------------------