Hello Team,
I have created 2 actions in my workflow to check the ntpd service status and it starts the service if the service is not running.
It appears that when the restart action only contains single command "/sbin/service ntpd restart" and the service is getting terminated abruptly. If I add few more commands after the restart command then there is no problem with the action.
Can you please take a look at this bug and provide a fix?
Action for restart the service:
$ cat ntp_admin_restart.yaml
---
description: 'Restart ntpd on a server'
enabled: true
entry_point: scripts/ntp_restart.sh
name: ntp_restart
runner_type: remote-shell-script
parameters:
action:
description: "Run as an action. (Outputs structured data)"
default: true
immutable: true
type: boolean
dir:
default: "/home/admin/"
immutable: true
cwd:
default: "/home/admin/"
immutable: true
debug:
description: "Turn on debug output"
default: false
type: boolean
sudo:
default: true
immutable: true
passphrase:
default: "{{ st2kv.admin_passphrase | decrypt_kv}}"
type: string
required: true
private_key:
default: "/home/admin/.ssh/id_rsa"
required: true
username:
default: "admin"
required: true
Script for above action:
$ cat scripts/ntp_restart.sh
#!/bin/bash
/etc/init.d/ntpd start
exit 0
# service ntpd status
ntpd dead but subsys locked
Action for check the service status:
ntp_check.yaml
---
description: 'Check ntp on a server'
enabled: true
entry_point: scripts/check_service.sh
name: ntp_check
runner_type: remote-shell-script
parameters:
action:
description: "Run as an action. (Outputs structured data)"
default: true
immutable: true
type: boolean
dir:
default: "/home/admin/"
immutable: true
cwd:
default: "/home/admin/"
immutable: true
debug:
description: "Turn on debug output"
default: false
type: boolean
sudo:
default: true
immutable: true
passphrase:
default: "{{ st2kv.admin_passphrase | decrypt_kv}}"
type: string
required: true
private_key:
default: "/home/admin/.ssh/id_rsa"
required: true
username:
default: "admin"
required: true
#check ntpd process
pgrep ntpd 2>/dev/null 1>&2
if [ $? != 0 ];then
exit 1
fi
cat workflows/dmin_ntp_workflow.yaml
---
version: '2.0'
ops.admin_ntp_procs_workflow:
type: direct
input:
- hostname
tasks:
verify:
action: ops.ntp_check
input:
hosts: <% $.hostname %>
on-error:
- remediate
remediate:
action: ops.ntp_restart
input:
hosts: <% $.hostname %>
on-complete:
- postcheck
postcheck:
action: ops.ntp_check
input:
hosts: <% $.hostname %>
After above execution:
+--------------------------+------------------------+-----------+--------------------------+-------------------------------+
| id | status | task | action | start_timestamp |
+--------------------------+------------------------+-----------+--------------------------+-------------------------------+
| 59bfa6b42d0549041063f6f0 | failed (4s elapsed) | verify | ops.ntp_check | Mon, 18 Sep 2017 10:57:56 UTC |
| 59bfa6b82d0549041063f6f2 | succeeded (9s elapsed) | remediate | ops.ntp_restart | Mon, 18 Sep 2017 10:58:00 UTC |
| 59bfa6c12d0549041063f6f4 | failed (4s elapsed) | postcheck | ops.ntp_check | Mon, 18 Sep 2017 10:58:09 UTC |
+--------------------------+------------------------+-----------+--------------------------+-------------------------------+
Hello Team,
I have created 2 actions in my workflow to check the ntpd service status and it starts the service if the service is not running.
It appears that when the restart action only contains single command "/sbin/service ntpd restart" and the service is getting terminated abruptly. If I add few more commands after the restart command then there is no problem with the action.
Can you please take a look at this bug and provide a fix?
Action for restart the service:
$ cat ntp_admin_restart.yamlScript for above action:
# service ntpd status ntpd dead but subsys lockedAction for check the service status:
ntp_check.yamlcat workflows/dmin_ntp_workflow.yamlAfter above execution: