diff --git a/roles/one_agent/files/host/data/.gitkeep b/roles/one_agent/files/host/data/disk/.gitkeep similarity index 100% rename from roles/one_agent/files/host/data/.gitkeep rename to roles/one_agent/files/host/data/disk/.gitkeep diff --git a/roles/one_agent/files/host/os_binary/exem-host-agent_aix-5.3-powerpc-64 b/roles/one_agent/files/host/os_binary/exem-host-agent_aix-5.3-powerpc-64 index 9353db6..18ca81e 100755 Binary files a/roles/one_agent/files/host/os_binary/exem-host-agent_aix-5.3-powerpc-64 and b/roles/one_agent/files/host/os_binary/exem-host-agent_aix-5.3-powerpc-64 differ diff --git a/roles/one_agent/files/host/os_binary/exem-host-agent_aix-7.1-powerpc-64 b/roles/one_agent/files/host/os_binary/exem-host-agent_aix-7.1-powerpc-64 index 07ad2fb..42c7db9 100755 Binary files a/roles/one_agent/files/host/os_binary/exem-host-agent_aix-7.1-powerpc-64 and b/roles/one_agent/files/host/os_binary/exem-host-agent_aix-7.1-powerpc-64 differ diff --git a/roles/one_agent/files/host/os_binary/exem-host-agent_linux-2.6-x86_64-64 b/roles/one_agent/files/host/os_binary/exem-host-agent_linux-2.6-x86_64-64 index 1cb8184..1099c5f 100755 Binary files a/roles/one_agent/files/host/os_binary/exem-host-agent_linux-2.6-x86_64-64 and b/roles/one_agent/files/host/os_binary/exem-host-agent_linux-2.6-x86_64-64 differ diff --git a/roles/one_agent/files/host/script/systemctl_disable.sh b/roles/one_agent/files/host/script/systemctl_disable.sh new file mode 100755 index 0000000..55ce7a9 --- /dev/null +++ b/roles/one_agent/files/host/script/systemctl_disable.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +SYSTEMCTL=$(which systemctl 2> /dev/null) +SERVICE=$(which service 2> /dev/null) +CHKCONFIG=$(which chkconfig 2> /dev/null) + + +if [ -n "${SYSTEMCTL}" ]; then + systemctl stop exem-host-agent + systemctl disable exem-host-agent + systemctl daemon-reload + + if [ -e "/etc/systemd/system/exem-host-agent.service" ]; then + rm -f /etc/systemd/system/exem-host-agent.service + systemctl daemon-reload + fi + + if [ -e "/etc/systemd/system/default.target.wants/exem-host-agent.service" ]; then + rm -f /etc/systemd/system/default.target.wants/exem-host-agent.service + systemctl daemon-reload + fi + + echo "exem-host-agent is disabled" +fi + diff --git a/roles/one_agent/tasks/host-agent.yml b/roles/one_agent/tasks/host-agent.yml index 402c3d0..1b5cd64 100644 --- a/roles/one_agent/tasks/host-agent.yml +++ b/roles/one_agent/tasks/host-agent.yml @@ -6,7 +6,6 @@ mode: '0755' - name: Copy exemONE Host-Agent File -# ansible.posix.synchronize: ansible.builtin.copy: src: "{{ role_path }}/files/host" dest: "{{ EXEM_HOME }}" @@ -20,6 +19,7 @@ - binary_start.sh - binary_stop.sh - systemctl_stop.sh + - systemctl_enable.sh - name: Create Service Script ansible.builtin.template: diff --git a/roles/one_agent/templates/systemctl_enable.sh.j2 b/roles/one_agent/templates/systemctl_enable.sh.j2 new file mode 100644 index 0000000..e558fda --- /dev/null +++ b/roles/one_agent/templates/systemctl_enable.sh.j2 @@ -0,0 +1,32 @@ +#!/bin/sh + +SYSTEMCTL=$(which systemctl 2> /dev/null) +SERVICE=$(which service 2> /dev/null) +CHKCONFIG=$(which chkconfig 2> /dev/null) + + +if [ "$(id -u)" -ne 0 ]; then + echo "Not a root user. Not support service registration" + echo "Use binary mode" + exit 1 +fi + + +if [ -n "${SYSTEMCTL}" ]; then + # SELinux setting + chcon -t bin_t {{ EXEM_HOME }}/host/script/binary_start.sh + chcon -R -t var_run_t {{ EXEM_HOME }}/host/data + chcon -R -t var_run_t {{ EXEM_HOME }}/host/service + + if [ ! -e "/etc/systemd/system/exem-host-agent.service" ]; then + systemctl enable {{ EXEM_HOME }}/host/service/exem-host-agent.service + fi + systemctl daemon-reload + + echo "exem-host-agent is enabled" + +else + echo "this OS version that does not support service registration" + echo "Use binary mode" + exit 1 +fi