From aec163262741d9427057e0caeff3e0d6e16c7ef7 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Mon, 16 Dec 2013 16:19:27 +0100 Subject: [PATCH 1/2] on older systems, zypper service and zypper repos doesn't know the parameter -E, so we need a way which works on older releases too --- cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids | 4 +++- cdist/conf/type/__zypper_service/explorer/repo_ids | 5 ++++- cdist/conf/type/__zypper_service/explorer/service_id | 4 +++- cdist/conf/type/__zypper_service/explorer/service_ids | 4 +++- cdist/conf/type/__zypper_service/explorer/service_uri | 4 +++- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids index a0d092b1..2dfb946f 100644 --- a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids @@ -21,4 +21,6 @@ # Retrieve all repo id nummbers from enabled repos - parsed zypper output # # -echo $(zypper lr -E | cut -d'|' -f 1 | grep -E '^[0-9]') +# simpler command which works only on SLES11 SP3 or newer: +# echo $(zypper lr -E | cut -d'|' -f 1 | grep -E '^[0-9]') +echo $(zypper lr | grep -E '^[0-9]([^|]+\|){3,3} Yes' | cut -d'|' -f 1) diff --git a/cdist/conf/type/__zypper_service/explorer/repo_ids b/cdist/conf/type/__zypper_service/explorer/repo_ids index 8c32b40b..e831b76c 100644 --- a/cdist/conf/type/__zypper_service/explorer/repo_ids +++ b/cdist/conf/type/__zypper_service/explorer/repo_ids @@ -21,4 +21,7 @@ # Manage services with Zypper (mostly suse) # # -echo $(zypper lr -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') +# simpler command which works only on SLES11 SP3 or newer: +# echo $(zypper lr -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') +# on older systems, zypper doesn't know the parameter -E +echo $(zypper lr -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_id b/cdist/conf/type/__zypper_service/explorer/service_id index b473340c..9c3d3a2d 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_id +++ b/cdist/conf/type/__zypper_service/explorer/service_id @@ -25,4 +25,6 @@ if [ -f "$__object/parameter/service_uri" ]; then else uri="/$__object_id" fi -echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 1 ) +# simpler command which works only on SLES11 SP3 or newer: +# echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 1 ) +echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\<$uri\>" | cut -d'|' -f 1 ) diff --git a/cdist/conf/type/__zypper_service/explorer/service_ids b/cdist/conf/type/__zypper_service/explorer/service_ids index 460b2006..0f1f4186 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_ids +++ b/cdist/conf/type/__zypper_service/explorer/service_ids @@ -20,4 +20,6 @@ # # Manage services with Zypper (mostly suse) # -echo $(zypper ls -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') +# simpler command which works only on SLES11 SP3 or newer: +# echo $(zypper ls -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') +echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_uri b/cdist/conf/type/__zypper_service/explorer/service_uri index aec93cb2..2f4f8960 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_uri +++ b/cdist/conf/type/__zypper_service/explorer/service_uri @@ -25,4 +25,6 @@ if [ -f "$__object/parameter/service_uri" ]; then else uri="/$__object_id" fi -echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 7 ) +# simpler command which works only on SLES11 SP3 or newer: +# echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 7) +echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\<$uri\>" | cut -d'|' -f 7 ) From a70d478f9e6b26d86f51615e2087ad4df854e79f Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Mon, 16 Dec 2013 17:07:49 +0100 Subject: [PATCH 2/2] fixed a minor type with param remove-all-other-services --- cdist/conf/type/__zypper_service/man.text | 4 ++-- cdist/conf/type/__zypper_service/parameter/boolean | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__zypper_service/man.text b/cdist/conf/type/__zypper_service/man.text index b1717c96..31543d93 100644 --- a/cdist/conf/type/__zypper_service/man.text +++ b/cdist/conf/type/__zypper_service/man.text @@ -33,7 +33,7 @@ type:: BOOLEAN PARAMETERS ------------------ -remove-all-other-service:: +remove-all-other-services:: Drop all other services found on the target host before adding the new one. remove-all-repos:: @@ -45,7 +45,7 @@ EXAMPLES -------------------------------------------------------------------------------- # Ensure that internal SLES11 SP3 RIS is in installed and all other services and repos are discarded -__zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --service_uri "http://path/to/your/ris/dir" --remove-all-other-service --remove-all-repos +__zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --service_uri "http://path/to/your/ris/dir" --remove-all-other-services --remove-all-repos # Ensure that internal SLES11 SP3 RIS is in installed, no changes to ohter services or repos __zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --service_uri "http://path/to/your/ris/dir" diff --git a/cdist/conf/type/__zypper_service/parameter/boolean b/cdist/conf/type/__zypper_service/parameter/boolean index bc6a5629..ca711ded 100644 --- a/cdist/conf/type/__zypper_service/parameter/boolean +++ b/cdist/conf/type/__zypper_service/parameter/boolean @@ -1,2 +1,2 @@ -remove-all-other-service +remove-all-other-services remove-all-repos