exemONE Agent Installer 작성
This commit is contained in:
BIN
roles/one_agent/.DS_Store
vendored
Normal file
BIN
roles/one_agent/.DS_Store
vendored
Normal file
Binary file not shown.
38
roles/one_agent/README.md
Normal file
38
roles/one_agent/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
Role Name
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||
2
roles/one_agent/defaults/main.yml
Normal file
2
roles/one_agent/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# defaults file for one_agent
|
||||
BIN
roles/one_agent/files/.DS_Store
vendored
Normal file
BIN
roles/one_agent/files/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
roles/one_agent/files/container/bin/exem-container-agent
Executable file
BIN
roles/one_agent/files/container/bin/exem-container-agent
Executable file
Binary file not shown.
BIN
roles/one_agent/files/host/os_binary/exem-host-agent_linux-2.6-x86_64-64
Executable file
BIN
roles/one_agent/files/host/os_binary/exem-host-agent_linux-2.6-x86_64-64
Executable file
Binary file not shown.
3
roles/one_agent/files/host/script/service_start.sh
Executable file
3
roles/one_agent/files/host/script/service_start.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
service exem-host-agent start
|
||||
3
roles/one_agent/files/host/script/service_stop.sh
Executable file
3
roles/one_agent/files/host/script/service_stop.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
service exem-host-agent stop
|
||||
3
roles/one_agent/files/host/script/systemctl_start.sh
Executable file
3
roles/one_agent/files/host/script/systemctl_start.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
sudo systemctl start exem-host-agent
|
||||
BIN
roles/one_agent/files/rpm/rhel7.rpm
Executable file
BIN
roles/one_agent/files/rpm/rhel7.rpm
Executable file
Binary file not shown.
BIN
roles/one_agent/files/rpm/rhel8.rpm
Executable file
BIN
roles/one_agent/files/rpm/rhel8.rpm
Executable file
Binary file not shown.
BIN
roles/one_agent/files/rpm/rhel9.rpm
Executable file
BIN
roles/one_agent/files/rpm/rhel9.rpm
Executable file
Binary file not shown.
2
roles/one_agent/handlers/main.yml
Normal file
2
roles/one_agent/handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for one_agent
|
||||
52
roles/one_agent/meta/main.yml
Normal file
52
roles/one_agent/meta/main.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
# platforms:
|
||||
# - name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 25
|
||||
# - name: SomePlatform
|
||||
# versions:
|
||||
# - all
|
||||
# - 1.0
|
||||
# - 7
|
||||
# - 99.99
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
23
roles/one_agent/tasks/container-agent.yml
Normal file
23
roles/one_agent/tasks/container-agent.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
- name: Create exemONE Agent Directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ EXEM_HOME }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy exemONE Container-Agent File
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ role_path }}/files/container"
|
||||
dest: "{{ EXEM_HOME }}"
|
||||
|
||||
- name: Create Agent Script
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "{{ EXEM_HOME }}/container/{{ item }}"
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- start.sh
|
||||
- stop.sh
|
||||
|
||||
- name: exem-container-agent start
|
||||
ansible.builtin.shell: "{{ EXEM_HOME }}/container/start.sh"
|
||||
57
roles/one_agent/tasks/host-agent.yml
Normal file
57
roles/one_agent/tasks/host-agent.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
- name: Create exemONE Agent Directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ EXEM_HOME }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy exemONE Host-Agent File
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ role_path }}/files/host"
|
||||
dest: "{{ EXEM_HOME }}"
|
||||
|
||||
- name: Create Agent Script
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "{{ EXEM_HOME }}/host/script/{{ item }}"
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- binary_start.sh
|
||||
- binary_stop.sh
|
||||
- systemctl_stop.sh
|
||||
|
||||
- name: Create Service Script
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "{{ EXEM_HOME }}/host/service/{{ item }}"
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- exem-host-agent
|
||||
- exem-host-agent.service
|
||||
|
||||
- name: Move exem-host-agent Binary
|
||||
ansible.builtin.copy:
|
||||
src: "{{ EXEM_HOME }}/host/os_binary/exem-host-agent_linux-2.6-x86_64-64"
|
||||
dest: "{{ EXEM_HOME }}/host/bin/exem-host-agent"
|
||||
mode: '0755'
|
||||
|
||||
- name: Setting SELinux
|
||||
ansible.builtin.shell: |
|
||||
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/
|
||||
|
||||
- name: Create Symbolic link
|
||||
ansible.builtin.file:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
state: link
|
||||
loop:
|
||||
- { src: "{{ EXEM_HOME }}/host/service/exem-host-agent.service", dest: /etc/systemd/system/exem-host-agent.service }
|
||||
- { src: "{{ EXEM_HOME }}/host/service/exem-host-agent", dest: /usr/bin/exem-host-agent }
|
||||
|
||||
- name: exem-host-agent start and enable
|
||||
ansible.builtin.service:
|
||||
name: exem-host-agent
|
||||
state: started
|
||||
enabled: yes
|
||||
13
roles/one_agent/tasks/main.yml
Normal file
13
roles/one_agent/tasks/main.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- include_tasks: rsync.yml
|
||||
|
||||
- include_tasks: host-agent.yml
|
||||
when:
|
||||
- agent_list | select('search', 'host-agent') | list | count > 0
|
||||
- "'host_agent' in group_names"
|
||||
|
||||
- include_tasks: container-agent.yml
|
||||
when:
|
||||
- agent_list | select('search', 'container-agent') | list | count > 0
|
||||
- "'container_agent' in group_names"
|
||||
|
||||
45
roles/one_agent/tasks/rsync.yml
Normal file
45
roles/one_agent/tasks/rsync.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
- name: Create exemONE Agent Directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ EXEM_HOME }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy rsync install rpm OS - 7
|
||||
ansible.builtin.copy:
|
||||
src: "{{ role_path }}/files/rpm/rhel7.rpm"
|
||||
dest: "{{ EXEM_HOME }}/rhel7.rpm"
|
||||
mode: '0755'
|
||||
when: ansible_distribution_major_version == '7'
|
||||
|
||||
- name: install rsync os version 7
|
||||
ansible.builtin.yum:
|
||||
name: "{{ EXEM_HOME }}/rhel7.rpm"
|
||||
state: present
|
||||
when: ansible_distribution_major_version == '7'
|
||||
|
||||
- name: Copy rsync install rpm OS - 8
|
||||
ansible.builtin.copy:
|
||||
src: "{{ role_path }}/files/rpm/rhel8.rpm"
|
||||
dest: "{{ EXEM_HOME }}/rhel8.rpm"
|
||||
mode: '0755'
|
||||
when: ansible_distribution_major_version == '8'
|
||||
|
||||
- name: install rsync os version 8
|
||||
ansible.builtin.yum:
|
||||
name: "{{ EXEM_HOME }}/rhel8.rpm"
|
||||
state: present
|
||||
when: ansible_distribution_major_version == '8'
|
||||
|
||||
- name: Copy rsync install rpm OS - 9
|
||||
ansible.builtin.copy:
|
||||
src: "{{ role_path }}/files/rpm/rhel9.rpm"
|
||||
dest: "{{ EXEM_HOME }}/rhel9.rpm"
|
||||
mode: '0755'
|
||||
when: ansible_distribution_major_version == '9'
|
||||
|
||||
- name: install rsync os version 9
|
||||
ansible.builtin.yum:
|
||||
name: "{{ role_path }}/files/rpm/rhel9.rpm"
|
||||
state: present
|
||||
when: ansible_distribution_major_version == '9'
|
||||
26
roles/one_agent/templates/binary_start.sh.j2
Normal file
26
roles/one_agent/templates/binary_start.sh.j2
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EXPORT
|
||||
export EXEM_HOME={{ EXEM_HOME }}
|
||||
export EXEM_HOST_HOME={{ EXEM_HOME }}/host
|
||||
export RECEIVER_ADDR={{ RECEIVER_ADDR }}:{{ RECEIVER_PORT | default('9010') }}
|
||||
|
||||
|
||||
# START
|
||||
PIDFILE=${EXEM_HOST_HOME}/data/host_agent_pid
|
||||
|
||||
if [ -f "${PIDFILE}" ]; then
|
||||
PID=$(echo -n | cat ${PIDFILE})
|
||||
IS_RUNNING=$(ps -fp "${PID}" | grep -c exem-host-agent)
|
||||
|
||||
if [ "${IS_RUNNING}" -ne 0 ]; then
|
||||
echo "exem-host-agent is already running (${PID})"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
chmod 755 ${EXEM_HOST_HOME}/bin/exem-host-agent
|
||||
|
||||
ulimit -n 1024
|
||||
|
||||
${EXEM_HOST_HOME}/bin/exem-host-agent -D
|
||||
39
roles/one_agent/templates/binary_stop.sh.j2
Normal file
39
roles/one_agent/templates/binary_stop.sh.j2
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EXPORT
|
||||
export EXEM_HOME={{ EXEM_HOME }}
|
||||
export EXEM_HOST_HOME={{ EXEM_HOME }}/host
|
||||
|
||||
|
||||
# STOP
|
||||
PIDFILE=${EXEM_HOST_HOME}/data/host_agent_pid
|
||||
|
||||
if [ -f "${PIDFILE}" ]; then
|
||||
PID=$(echo -n | cat ${PIDFILE})
|
||||
mv ${PIDFILE} ${PIDFILE}.stopped
|
||||
|
||||
# WAITING
|
||||
LIMIT_CNT=10
|
||||
CNT=0
|
||||
while [ ${CNT} -lt ${LIMIT_CNT} ];
|
||||
do
|
||||
IS_RUNNING=$(ps -fp "${PID}" | grep -c exem-host-agent)
|
||||
if [ "${IS_RUNNING}" -ne 0 ]; then
|
||||
CNT=$((CNT+1))
|
||||
echo "exem-host-agent is stopping (${PID}) ..."
|
||||
sleep 1
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${CNT} -ge ${LIMIT_CNT} ]; then
|
||||
echo "Something is wrong. Check exem-host-agent (${PID})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "exem-host-agent is stopped (${PID})"
|
||||
|
||||
else
|
||||
echo "exem-host-agent is not running"
|
||||
fi
|
||||
29
roles/one_agent/templates/exem-host-agent.j2
Normal file
29
roles/one_agent/templates/exem-host-agent.j2
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Startup script for exemONE exem-host-agent
|
||||
# chkconfig: 345 50 50
|
||||
# description: exemONE exem-host-agent
|
||||
# processname: exem-host-agent
|
||||
# directory : EXEM_HOST_HOME={{ EXEM_HOME }}
|
||||
|
||||
source /etc/profile
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo "Starting exem-host-agent: "
|
||||
{{ EXEM_HOME }}/host/script/binary_start.sh
|
||||
;;
|
||||
stop)
|
||||
echo "Shutting down exem-host-agent: "
|
||||
{{ EXEM_HOME }}/host/script/binary_stop.sh
|
||||
;;
|
||||
restart)
|
||||
echo "Restarting exem-host-agent: "
|
||||
{{ EXEM_HOME }}/host/script/binary_stop.sh
|
||||
{{ EXEM_HOME }}/host/script/binary_start.sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: service exem-host-agent { start | stop | restart }"
|
||||
exit 1
|
||||
esac
|
||||
exit 0
|
||||
15
roles/one_agent/templates/exem-host-agent.service.j2
Normal file
15
roles/one_agent/templates/exem-host-agent.service.j2
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=exem-host-agent
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile={{ EXEM_HOME }}/host/data/host_agent_pid
|
||||
ExecStart={{ EXEM_HOME }}/host/script/binary_start.sh
|
||||
ExecStartPost=/bin/sleep 1
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
26
roles/one_agent/templates/start.sh.j2
Normal file
26
roles/one_agent/templates/start.sh.j2
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EXPORT
|
||||
export EXEM_HOME={{ EXEM_HOME }}
|
||||
export EXEM_CONTAINER_HOME={{ EXEM_HOME }}/container
|
||||
export COMMON_RECEIVER_IP={{ RECEIVER_ADDR }}
|
||||
export COMMON_RECEIVER_PORT={{ RECEIVER_CONTAINER_PORT | default('9009') }}
|
||||
export CONTAINER_LOG_LEVEL=info
|
||||
|
||||
|
||||
# START
|
||||
PIDFILE=${EXEM_CONTAINER_HOME}/data/container_agent_pid
|
||||
|
||||
if [ -f "${PIDFILE}" ]; then
|
||||
PID=$(echo -n | cat ${PIDFILE})
|
||||
IS_RUNNING=$(ps -fp "${PID}" | grep -c exem-container-agent)
|
||||
|
||||
if [ "${IS_RUNNING}" -ne 0 ]; then
|
||||
echo "exem-container-agent is already running (${PID})"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
chmod 755 ${EXEM_CONTAINER_HOME}/bin/exem-container-agent
|
||||
|
||||
${EXEM_CONTAINER_HOME}/bin/exem-container-agent run
|
||||
39
roles/one_agent/templates/stop.sh.j2
Normal file
39
roles/one_agent/templates/stop.sh.j2
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EXPORT
|
||||
export EXEM_HOME={{ EXEM_HOME }}
|
||||
export EXEM_CONTAINER_HOME={{ EXEM_HOME }}/container
|
||||
|
||||
|
||||
# STOP
|
||||
PIDFILE=${EXEM_CONTAINER_HOME}/data/container_agent_pid
|
||||
|
||||
if [ -f "${PIDFILE}" ]; then
|
||||
PID=$(echo -n | cat ${PIDFILE})
|
||||
mv ${PIDFILE} ${PIDFILE}.stopped
|
||||
|
||||
# WAITING
|
||||
LIMIT_CNT=10
|
||||
CNT=0
|
||||
while [ ${CNT} -lt ${LIMIT_CNT} ];
|
||||
do
|
||||
IS_RUNNING=$(ps -fp "${PID}" | grep -c exem-container-agent)
|
||||
if [ "${IS_RUNNING}" -ne 0 ]; then
|
||||
CNT=$((CNT+1))
|
||||
echo "exem-container-agent is stopping (${PID}) ..."
|
||||
sleep 1
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${CNT} -ge ${LIMIT_CNT} ]; then
|
||||
echo "Something is wrong. Check exem-container-agent (${PID})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "exem-container-agent is stopped (${PID})"
|
||||
|
||||
else
|
||||
echo "exem-container-agent is not running"
|
||||
fi
|
||||
5
roles/one_agent/templates/systemctl_stop.sh.j2
Normal file
5
roles/one_agent/templates/systemctl_stop.sh.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
sudo {{ EXEM_HOME }}/host/script/binary_stop.sh
|
||||
|
||||
sudo systemctl stop exem-host-agent
|
||||
2
roles/one_agent/tests/inventory
Normal file
2
roles/one_agent/tests/inventory
Normal file
@@ -0,0 +1,2 @@
|
||||
localhost
|
||||
|
||||
5
roles/one_agent/tests/test.yml
Normal file
5
roles/one_agent/tests/test.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- one_agent
|
||||
2
roles/one_agent/vars/main.yml
Normal file
2
roles/one_agent/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for one_agent
|
||||
Reference in New Issue
Block a user