Project

General

Profile

Actions

Bug #19157

closed

Command "rudder agent policy-server <server ip>" return code = 1 when ok

Added by Axel Bouet over 3 years ago. Updated over 3 years ago.

Status:
Released
Priority:
N/A
Category:
Agent
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
To do
Fix check:
Checked
Regression:

Description

Hello,
During an ansible development, I could see that the command "rudder agent policy-server <server ip>" returns the code 1 while the command worked well.

---
[root@server01 ~]# rudder agent policy-server 10....
[root@server01 ~]# echo $?
1
---

So ansible concider that the command failed.
I found two possibilities :

- change the logic of ansible with failed_when / changed_when

- modify the file /opt/rudder/share/commands/agent-policy-server and add "|| exit 0" at the end of the last line
---
[ $? ne 0 ] && printf "${RED}error${NORMAL}: Could not set policy server\n" || exit 0
--

Thanks.

Actions #1

Updated by Axel Bouet over 3 years ago

  • Subject changed from TCommand "rudder agent policy-server <server ip>" return code = 1 when ok to Command "rudder agent policy-server <server ip>" return code = 1 when ok
Actions #2

Updated by Axel Bouet over 3 years ago

[root@server01 ~]# rudder agent version
Rudder agent 6.2.4.release

Actions #3

Updated by Benoît PECCATTE over 3 years ago

This looks like a bug, it should return 0 if it works.
The code is pretty simple, i don't see where is return 1 except on a root server.
What is the output of the command ?
If there is none, could you run it in set -x ?

Actions #4

Updated by Axel Bouet over 3 years ago

Benoît PECCATTE wrote in #note-3:

This looks like a bug, it should return 0 if it works.
The code is pretty simple, i don't see where is return 1 except on a root server.
What is the output of the command ?
If there is none, could you run it in set -x ?

No output with this command.

Here is the return with :
set -x :

[root@server01 ~]#set -x
[root@server01 ~]#rudder agent policy-server 172.16.99.99
+ rudder agent policy-server 172.16.99.99
++ printf '\033]0;%s@%s:%s\007' root server01 '~'
[root@server01 ~]#set +x

and :
set -x added in scripts /bin/rudder and /opt/rudder/share/commands/agent-policy-server :

[root@server01 ~]#rudder agent policy-server 172.16.99.99
+ BASEDIR=/opt/rudder/share/commands
+ export BASEDIR
++ dirname /bin/rudder
+ REL_PATH=/bin
++ cd /bin
++ pwd
+ ABS_PATH=/bin
++ basename /bin/rudder
+ RUDDER_BIN=/bin/rudder
+ export RUDDER_BIN
+ PATH=/opt/rudder/bin:/usr/gnu/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin:/usr/sbin
+ export PATH
++ sed 's/[^[:alpha:]_-]*//g'
++ echo agent
+ role=agent
+ '[' agent = help ']'
+ '[' -z agent ']'
+ shift
++ role_list
++ ls /opt/rudder/share/commands
++ sed 's/\([[:alpha:]_]*\)-.*/\1/'
++ uniq
+ for installed_role in '`role_list`'
+ '[' agent = agent ']'
+ role_ok=y
+ for installed_role in '`role_list`'
+ '[' agent = directive ']'
+ for installed_role in '`role_list`'
+ '[' agent = relay ']'
+ for installed_role in '`role_list`'
+ '[' agent = remote ']'
+ for installed_role in '`role_list`'
+ '[' agent = server ']'
+ '[' y '!=' y ']'
+ '[' -x /opt/rudder/share/commands/agent ']'
++ sed 's/[^[:alpha:]_-]*//g'
++ echo policy-server
+ command=policy-server
+ '[' policy-server = help ']'
+ '[' policy-server = '' ']'
+ shift
+ '[' '!' -f /opt/rudder/share/commands/agent-policy-server ']'
++ sed 's/[^[:alpha:]_-]*//g'
++ echo 172.16.99.99
+ option=
+ '[' '' = --help ']'
+ '[' '' = -h ']'
+ '[' '' = help ']'
++ id -u
+ '[' 0 '!=' 0 ']'
+ exec /opt/rudder/share/commands/agent-policy-server 172.16.99.99
+ . /opt/rudder/share/commands/../lib/common.sh
++ RUDDER_VAR=/var/rudder
++ RUDDER_DIR=/opt/rudder
++ RUDDER_JSON=/var/rudder/cfengine-community/inputs/rudder.json
++ DEBUG_CLASS='-D trace'
++ VERBOSE_CLASS='-D debug'
++ INFO_CLASS='-D info'
++ '[' -t 1 ']'
++ COLOR=-Calways
++ GREEN='\033[1;32m'
++ DARKGREEN='\033[0;32m'
++ RED='\033[1;31m'
++ BLUE='\033[1;34m'
++ TPINK='\033[1;35m'
++ WHITE='\033[0;02m'
++ WHITELIGHT='\033[1;08m'
++ MAGENTA='\033[1;35m'
++ YELLOW='\033[1;33m'
++ CYAN='\033[1;36m'
++ NORMAL='\033[0;39m\033[0;49m'
++ DBLUE='\033[0;34m'
++ DGREEN='\033[0;32m'
++ '[' -f /var/rudder/cfengine-community/inputs/rudder.json ']'
+++ rudder_json_value RUDDER_REPORT_MODE
+++ grep RUDDER_REPORT_MODE /var/rudder/cfengine-community/inputs/rudder.json
+++ sed 's/.*"RUDDER_REPORT_MODE" *: *"\(.*\)",.*/\1/'
++ RUDDER_REPORT_MODE=full-compliance
+++ rudder_json_value AGENT_RUN_INTERVAL
+++ grep AGENT_RUN_INTERVAL /var/rudder/cfengine-community/inputs/rudder.json
+++ sed 's/.*"AGENT_RUN_INTERVAL" *: *"\(.*\)",.*/\1/'
++ AGENT_RUN_INTERVAL=5
+++ rudder_json_value RUDDER_NODE_CONFIG_ID
+++ grep RUDDER_NODE_CONFIG_ID /var/rudder/cfengine-community/inputs/rudder.json
+++ sed 's/.*"RUDDER_NODE_CONFIG_ID" *: *"\(.*\)",.*/\1/'
++ RUDDER_NODE_CONFIG_ID=20210415-071322-1a1eb61e
+++ rudder_json_value RUDDER_SYSLOG_PROTOCOL
+++ grep RUDDER_SYSLOG_PROTOCOL /var/rudder/cfengine-community/inputs/rudder.json
+++ sed 's/.*"RUDDER_SYSLOG_PROTOCOL" *: *"\(.*\)",.*/\1/'
++ RUDDER_SYSLOG_PROTOCOL=UDP
+++ rudder_json_value RUDDER_VERIFY_CERTIFICATES
+++ grep RUDDER_VERIFY_CERTIFICATES /var/rudder/cfengine-community/inputs/rudder.json
+++ sed 's/.*"RUDDER_VERIFY_CERTIFICATES" *: *"\(.*\)",.*/\1/'
++ RUDDER_VERIFY_CERTIFICATES=false
++ '[' 5 = '' ']'
+++ cat /opt/rudder/etc/uuid.hive
++ UUID=8986e452-5778-47fc-adfb-cd9868d371b6
++ '[' 0 -ne 0 ']'
++ '[' full-compliance = changes-only ']'
++ '[' full-compliance = reports-disabled ']'
++ VERBOSITY='-I -D info'
++ FULL_COMPLIANCE=1
++ '[' false = true ']'
++ CERTIFICATE_OPTION=--insecure
+++ '[' -f /var/rudder/run/api-token ']'
++ TOKEN=
+++ uname -s
++ OS_FAMILY=Linux
+ SERVER_FILE=/var/rudder/cfengine-community/policy_server.dat
++ cat /var/rudder/cfengine-community/policy_server.dat
+ CURRENT=172.16.99.99
+ '[' 0 -ne 0 ']'
+ SERVER=172.16.99.99
+ '[' -z 172.16.99.99 ']'
+ '[' 8986e452-5778-47fc-adfb-cd9868d371b6 = root ']'
+ echo 172.16.99.99
+ '[' 0 -ne 0 ']'
[root@server01 ~]#echo $?
1

Actions #5

Updated by Benoît PECCATTE over 3 years ago

  • Target version set to 6.1.13
Actions #6

Updated by Benoît PECCATTE over 3 years ago

I see, the code is pretty simple and wrong.
You are right with your patch, I will submit a PR as soon as possible.

Actions #7

Updated by Benoît PECCATTE over 3 years ago

  • Status changed from New to In progress
  • Assignee set to Benoît PECCATTE
Actions #8

Updated by Benoît PECCATTE over 3 years ago

  • Status changed from In progress to Pending technical review
  • Assignee changed from Benoît PECCATTE to Alexis Mousset
  • Pull Request set to https://github.com/Normation/rudder-agent/pull/335
Actions #9

Updated by Benoît PECCATTE over 3 years ago

  • Status changed from Pending technical review to Pending release
Actions #10

Updated by Nicolas CHARLES over 3 years ago

  • Fix check changed from To do to Checked
Actions #11

Updated by Vincent MEMBRÉ over 3 years ago

  • Status changed from Pending release to Released

This bug has been fixed in Rudder 6.1.13 and 6.2.7 which were released today.

Actions

Also available in: Atom PDF