I have an init.d unit file which works fine through command line:
service ibmihs.service [start/stop]
However when I run through ansible it run successfully but the service won't start. I see this error in the log:
"stderr": "service ibmihs.service does not support chkconfig\n",
I am using Ansible Automation Platform Controller 4.3.0 and Red Hat Enterprise Linux Server release 6.10 (Santiago)
playbook:
- name: Include variables file
ansible.builtin.include_vars:
file: ../environments/Development/group_vars/role1/main.yml
- name: Start IBM HTTP Server administration server [adminctl]
become: yes
ansible.builtin.sysvinit:
name: "{{ ibm_adminctl_service_file }}"
state: started
enabled: yes
when:
hostvars[inventory_hostname].ansible_distribution_major_version == "6"
- name: Start IBM HTTP Server administration server [adminctl]
become: yes
ansible.builtin.service:
name: "{{ ibm_ihs_service_file }}"
state: started
enabled: yes
when:
hostvars[inventory_hostname].ansible_distribution_major_version >= "7"
ibm_ihs_service_file:
#!/bin/bash
user="root"
# get custom config
if [ -f /etc/sysconfig/ihs ]; then
. /etc/sysconfig/ihs
fi
start(){
echo "Starting IBM HTTP Server ..."
/opt/IBM/HTTPServer/bin/apachectl -k start
echo "Started"
}
stop(){
echo "Stopping IBM HTTP Server ..."
/opt/IBM/HTTPServer/bin/apachectl -k stop
echo "Stopped"
}
restart(){
stop
start
}
status(){
if [[ $(ps -ef | grep httpd | egrep -v 'grep|admin') ]]; then
echo "IBM HTTP Server is running"
else
echo "IBM HTTP Server is down"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
esac
task debug output:
<servername> ESTABLISH SSH CONNECTION FOR USER: useraccount
<servername> SSH: ansible.cfg set ssh_args: (-C)(-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<servername> SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)
<servername> SSH: ansible_password/ansible_ssh_password not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<servername> SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User="useraccount")
<servername> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<servername> SSH: PlayContext set ssh_common_args: ()
<servername> SSH: PlayContext set ssh_extra_args: ()
<servername> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/runner/cp/8b7f2e4887)
<servername> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="useraccount"' -o ConnectTimeout=10 -o ControlPath=/runner/cp/8b7f2e4887 servername '/bin/sh -c '"'"'rm -f -r /home/useraccount/.ansible/tmp/ansible-tmp-1692378171.4800231-45-220523256889857/ > /dev/null 2>&1 && sleep 0'"'"''
<servername> (0, b'', b"OpenSSH_8.0p1, OpenSSL 1.1.1k FIPS 25 Mar 2021\\r\\ndebug1: Reading configuration data /etc/ssh/ssh_config\\r\\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\\r\\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\\r\\ndebug2: checking match for 'final all' host servername originally servername\\r\\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'\\r\\ndebug2: match not found\\r\\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)\\r\\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\\r\\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\\r\\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\\r\\ndebug1: configuration requests final Match pass\\r\\ndebug1: re-parsing configuration\\r\\ndebug1: Reading configuration data /etc/ssh/ssh_config\\r\\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\\r\\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\\r\\ndebug2: checking match for 'final all' host servername originally servername\\r\\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'\\r\\ndebug2: match found\\r\\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\\r\\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\\r\\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\\r\\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\\r\\ndebug1: auto-mux: Trying existing master\\r\\ndebug2: fd 3 setting O_NONBLOCK\\r\\ndebug2: mux_client_hello_exchange: master version 4\\r\\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\\r\\ndebug3: mux_client_request_session: entering\\r\\ndebug3: mux_client_request_alive: entering\\r\\ndebug3: mux_client_request_alive: done pid = 33\\r\\ndebug3: mux_client_request_session: session request sent\\r\\ndebug3: mux_client_read_packet: read header failed: Broken pipe\\r\\ndebug2: Received exit status from master 0\\r\\n")
changed: [servername] => {
"changed": true,
"invocation": {
"module_args": {
"arguments": null,
"daemonize": false,
"enabled": true,
"name": "ibmihs.service",
"pattern": null,
"runlevels": null,
"sleep": 1,
"state": "started"
}
},
"name": "ibmihs.service",
"status": {
"enabled": {
"changed": true,
"rc": 1,
"stderr": "service ibmihs.service does not support chkconfig\\n",
"stdout": ""
},
"started": {
"changed": false,
"rc": null,
"stderr": null,
"stdout": null
}
}
}