Skip to content

Commit

Permalink
Ansible playbook + fixes for salt
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrusev committed Oct 28, 2015
1 parent b0b31ba commit c8fb521
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ To install the latest stable version of the Agent, issue the following command:

pip install https://github.com/amonapp/amonagent/archive/master.zip

### Install with Ansible/Salt

To install the amon-agent with Ansible or Salt, please take a look at the examples in the deployment directory.

## Credits / Contact

Contact martin@amon.cx with questions.
Expand Down
8 changes: 8 additions & 0 deletions deployment/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# =====================
# Test
# =====================
test_ansible:
cp ansible/Dockerfile Dockerfile
docker build --force-rm=true --rm=true --no-cache .
rm Dockerfile
docker rmi $$(docker images -q --filter dangling=true)
14 changes: 14 additions & 0 deletions deployment/ansible/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM williamyeh/ansible:centos7
# FROM williamyeh/ansible:ubuntu14.04

WORKDIR /tmp
COPY ansible /tmp

# ==> Creating inventory file...
RUN echo localhost > inventory

# ==> Executing Ansible...
RUN ansible-playbook -i inventory amon-agent.yml --connection=local


RUN cat /etc/amon-agent.conf
21 changes: 21 additions & 0 deletions deployment/ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Installing the amon-agent with Ansible

- Copy all the files from deployment/ansible to a local path
- In amon-agent.yml, replace the following variables with the appropriate values:

```
api_key - a valid API key
amon_instance - the IP or domain pointing to your Amon instance
```

## Running the playbook



```
ansible-playbook amon-agent.yml
```

Tested on Debian/Ubuntu and CentOS
4 changes: 4 additions & 0 deletions deployment/ansible/amon-agent.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"server_key": "{{machine_id}}",
"host": "{{amon_instance}}"
}
18 changes: 18 additions & 0 deletions deployment/ansible/amon-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- hosts: localhost
connection: local
sudo: True
vars:
api_key: uxIDpRApV3ULEnDUAwUNA6grHLBQs91iEiQsN8pIUao
amon_instance: http://192.168.72.128:9000
machine_id: "{{ ansible_machine_id | hash('md5') }}"
tasks:
- uri:
url: "{{amon_instance}}/api/v1/servers/create/?api_key={{api_key}}&key={{machine_id}}&name={{ansible_nodename}}"
method: GET
- include: ubuntu_debian.yml
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- include: centos.yml
when: ansible_distribution == 'CentOS'
- template: src=amon-agent.conf dest=/etc/amon-agent.conf owner=amonagent group=amonagent mode=0644
- command: /etc/init.d/amon-agent restart
5 changes: 5 additions & 0 deletions deployment/ansible/centos.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[amon-agent]
name=AmonAgent
gpgcheck=0
enabled=1
baseurl=http://packages.amon.cx/rpm
4 changes: 4 additions & 0 deletions deployment/ansible/centos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- template: src=centos.repo dest=/etc/yum.repos.d/amon.repo

- name: Install
yum: name=amon-agent state=latest
14 changes: 14 additions & 0 deletions deployment/ansible/ubuntu_debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- name: Add Amon agent repository key.
command: apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv AD53961F
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: Add repository - Debian/Ubuntu.
lineinfile: "dest=/etc/apt/sources.list.d/amonagent.list create=yes line='deb http://packages.amon.cx/repo amon contrib'"
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'


- name: Update.
command: apt-get update

- name: Install.
command: apt-get install -y --force-yes amon-agent
2 changes: 1 addition & 1 deletion deployment/salt/amon-agent/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ amon-agent:
- keyid: AD53961F
- keyserver: keyserver.ubuntu.com
{% elif grains['os_family'] == 'RedHat' %}
- baseurl: priority=1
- baseurl: http://packages.amon.cx/rpm/
- gpgcheck: 0
- enabled: 1
{% endif %}
Expand Down

0 comments on commit c8fb521

Please sign in to comment.