Skip to content

Commit de905b9

Browse files
tmicheletolivielpeau
authored andcommitted
[Tests] Add basic configuration on how to test when in dev mode (#88)
very basic setup based on vagrant
1 parent 64ab08c commit de905b9

File tree

8 files changed

+146
-1
lines changed

8 files changed

+146
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vagrant
2+
*.retry

tests/Vagrantfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Vagrant.configure("2") do |config|
2+
config.vm.box = "ubuntu/trusty64"
3+
end

tests/inventory

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[test_host]
2+
127.0.0.1 ansible_ssh_host=localhost ansible_ssh_user=vagrant ansible_ssh_port=2222 ansible_ssh_private_key_file=./ansible-datadog/tests/.vagrant/machines/default/virtualbox/private_key

tests/readme.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Test setup
2+
3+
This is an example setup, based on vagrant + virtualbox, that allows to easily run ansible commands to test the module.
4+
5+
# Requirements
6+
7+
- vagrant > 2.0.0
8+
- vitrualbox > 5.1.28
9+
10+
# Setup
11+
12+
in `$WORK_DIR/ansible-datadog/tests`:
13+
14+
- provision VM: `vagrant up`
15+
- connect to the VM to check the configuration: `vagrant ssh`
16+
- destroy VM when needed: `vagrant destroy -f`
17+
18+
in `$WORK_DIR`:
19+
20+
- run ansible-playbook: `ansible-playbook ansible-datadog/tests/test_5_full.yml -i ansible-datadog/tests/inventory`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
- hosts: localhost
2+
- hosts: all
33
roles:
44
- { role: ansible-datadog, become: yes }

tests/test_5_full.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
- hosts: all
2+
roles:
3+
- { role: ansible-datadog, become: yes } # On Ansible < 1.9, use `sudo: yes` instead of `become: yes`
4+
vars:
5+
datadog_api_key: "123456"
6+
datadog_agent_version: "1:5.18.0-1" # for apt-based platforms, use a `5.12.3-1` format on yum-based platforms
7+
datadog_agent_allow_downgrade: true
8+
datadog_config:
9+
tags: "mytag0, mytag1"
10+
log_level: INFO
11+
apm_enabled: "true" # has to be set as a string
12+
datadog_config_ex:
13+
trace.config:
14+
env: dev
15+
trace.concentrator:
16+
extra_aggregators: version
17+
datadog_checks:
18+
process:
19+
init_config:
20+
instances:
21+
- name: ssh
22+
search_string: ['ssh', 'sshd' ]
23+
- name: syslog
24+
search_string: ['rsyslog' ]
25+
cpu_check_interval: 0.2
26+
exact_match: true
27+
ignore_denied_access: true
28+
ssh_check:
29+
init_config:
30+
instances:
31+
- host: localhost
32+
port: 22
33+
username: root
34+
password: changeme
35+
sftp_check: True
36+
private_key_file:
37+
add_missing_keys: True
38+
nginx:
39+
init_config:
40+
instances:
41+
- nginx_status_url: http://example.com/nginx_status/
42+
tags:
43+
- instance:foo
44+
- nginx_status_url: http://example2.com:1234/nginx_status/
45+
tags:
46+
- instance:bar

tests/test_6_default.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- hosts: all
3+
roles:
4+
- { role: ansible-datadog, become: yes }
5+
vars:
6+
datadog_agent6: true

tests/test_6_full.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
- hosts: all
2+
roles:
3+
- { role: ansible-datadog, become: yes } # On Ansible < 1.9, use `sudo: yes` instead of `become: yes`
4+
vars:
5+
datadog_agent6: true
6+
datadog_api_key: "123456"
7+
datadog_agent_allow_downgrade: true
8+
datadog_config:
9+
tags: "mytag0, mytag1"
10+
log_level: INFO
11+
apm_enabled: "true" # has to be set as a string
12+
# logs related config
13+
log_enabled: true
14+
logset: main
15+
datadog_config_ex:
16+
trace.config:
17+
env: dev
18+
trace.concentrator:
19+
extra_aggregators: version
20+
datadog_checks:
21+
process:
22+
init_config:
23+
instances:
24+
- name: ssh
25+
search_string: ['ssh', 'sshd' ]
26+
- name: syslog
27+
search_string: ['rsyslog' ]
28+
cpu_check_interval: 0.2
29+
exact_match: true
30+
ignore_denied_access: true
31+
ssh_check:
32+
init_config:
33+
instances:
34+
- host: localhost
35+
port: 22
36+
username: root
37+
password: changeme
38+
sftp_check: True
39+
private_key_file:
40+
add_missing_keys: True
41+
nginx:
42+
init_config:
43+
instances:
44+
- nginx_status_url: http://example.com/nginx_status/
45+
tags:
46+
- instance:foo
47+
- nginx_status_url: http://example2.com:1234/nginx_status/
48+
tags:
49+
- instance:bar
50+
logs:
51+
- type: file
52+
path: /var/log/nginx.log
53+
service: nginx
54+
source: nginx
55+
sourcecategory: webapp
56+
tags: env:prod
57+
- type: tcp
58+
port: 10514
59+
service: webapp
60+
source: php
61+
sourcecategory: front
62+
log_processing_rules:
63+
- type: exclude_at_match
64+
name: exclude_datadoghq_users
65+
# Regexp can be anything
66+
pattern: User=\[email protected]

0 commit comments

Comments
 (0)