From 0f820238913452ea3b68ecf64b357182988fca00 Mon Sep 17 00:00:00 2001 From: gnmahanth <22050509+gnmahanth@users.noreply.github.com> Date: Thu, 20 Feb 2020 16:43:45 +0530 Subject: [PATCH] add ansible playbook to install agent on multiple nodes at once --- README.md | 17 ++++++++++++----- hosts.sample | 3 +++ playbook.yaml | 17 +++++++++++++++++ requirements.txt | 8 ++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 hosts.sample create mode 100644 playbook.yaml create mode 100644 requirements.txt diff --git a/README.md b/README.md index 54edf93..c033457 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ -# apm-agent +## Platforms tested +- ubuntu 18 lts +- ubuntu 16 lts +- centos 7 + +## apm-agent installer 1) download install.sh 2) execute **chmod +x install.sh** to give executable permision 3) run install.sh as root to install td-agent-bit and sfagent -## Platforms tested -- ubuntu 18 lts -- ubuntu 16 lts -- centos 7 \ No newline at end of file +## using ansible playbook +1) make sure targets nodes have python installed on them. +2) ansible playbook uses install.sh internally +3) install ansible using **pip install -r requirements.txt** +4) update hosts file, sample can be found in hosts.sample +5) execute command **ansible-playbook -vv -b -i hosts --key-file=ssh-key.pem playbook.yaml** \ No newline at end of file diff --git a/hosts.sample b/hosts.sample new file mode 100644 index 0000000..78c11a1 --- /dev/null +++ b/hosts.sample @@ -0,0 +1,3 @@ +[all] +centos ansible_host=10.81.1.220 ansible_ssh_user=centos +ubuntu ansible_host=10.81.1.143 ansible_ssh_user=ubuntu \ No newline at end of file diff --git a/playbook.yaml b/playbook.yaml new file mode 100644 index 0000000..2ad5bd3 --- /dev/null +++ b/playbook.yaml @@ -0,0 +1,17 @@ +--- +- name: install sfagent + become: yes + hosts: all + tasks: + - name: Transfer install.sh script + copy: src=install.sh dest=/tmp/install.sh mode=0777 + + - name: Execute install.sh + command: /tmp/install.sh + + # by default install.sh donot start sfagent uncomment below lines to start agent + # - name: start sfagent + # service: + # name: sfagent + # state: started + # enabled: yes \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..53f919c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +ansible==2.9.5 +cffi==1.14.0 +cryptography==2.8 +Jinja2==2.11.1 +MarkupSafe==1.1.1 +pycparser==2.19 +PyYAML==5.3 +six==1.14.0