diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a058c8c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vagrant +*.retry diff --git a/tests/Vagrantfile b/tests/Vagrantfile new file mode 100644 index 00000000..b4a4f311 --- /dev/null +++ b/tests/Vagrantfile @@ -0,0 +1,3 @@ +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/trusty64" +end diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 00000000..5a836b84 --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +[test_host] +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 diff --git a/tests/readme.md b/tests/readme.md new file mode 100644 index 00000000..dcd8d3e2 --- /dev/null +++ b/tests/readme.md @@ -0,0 +1,20 @@ +# Test setup + +This is an example setup, based on vagrant + virtualbox, that allows to easily run ansible commands to test the module. + +# Requirements + +- vagrant > 2.0.0 +- vitrualbox > 5.1.28 + +# Setup + +in `$WORK_DIR/ansible-datadog/tests`: + +- provision VM: `vagrant up` +- connect to the VM to check the configuration: `vagrant ssh` +- destroy VM when needed: `vagrant destroy -f` + +in `$WORK_DIR`: + +- run ansible-playbook: `ansible-playbook ansible-datadog/tests/test_5_full.yml -i ansible-datadog/tests/inventory` diff --git a/tests/test.yml b/tests/test_5_default.yml similarity index 74% rename from tests/test.yml rename to tests/test_5_default.yml index 476e63be..1012d56c 100644 --- a/tests/test.yml +++ b/tests/test_5_default.yml @@ -1,4 +1,4 @@ --- -- hosts: localhost +- hosts: all roles: - { role: ansible-datadog, become: yes } diff --git a/tests/test_5_full.yml b/tests/test_5_full.yml new file mode 100644 index 00000000..0eb461c5 --- /dev/null +++ b/tests/test_5_full.yml @@ -0,0 +1,46 @@ +- hosts: all + roles: + - { role: ansible-datadog, become: yes } # On Ansible < 1.9, use `sudo: yes` instead of `become: yes` + vars: + datadog_api_key: "123456" + datadog_agent_version: "1:5.18.0-1" # for apt-based platforms, use a `5.12.3-1` format on yum-based platforms + datadog_agent_allow_downgrade: true + datadog_config: + tags: "mytag0, mytag1" + log_level: INFO + apm_enabled: "true" # has to be set as a string + datadog_config_ex: + trace.config: + env: dev + trace.concentrator: + extra_aggregators: version + datadog_checks: + process: + init_config: + instances: + - name: ssh + search_string: ['ssh', 'sshd' ] + - name: syslog + search_string: ['rsyslog' ] + cpu_check_interval: 0.2 + exact_match: true + ignore_denied_access: true + ssh_check: + init_config: + instances: + - host: localhost + port: 22 + username: root + password: changeme + sftp_check: True + private_key_file: + add_missing_keys: True + nginx: + init_config: + instances: + - nginx_status_url: http://example.com/nginx_status/ + tags: + - instance:foo + - nginx_status_url: http://example2.com:1234/nginx_status/ + tags: + - instance:bar diff --git a/tests/test_6_default.yml b/tests/test_6_default.yml new file mode 100644 index 00000000..27f48a37 --- /dev/null +++ b/tests/test_6_default.yml @@ -0,0 +1,6 @@ +--- +- hosts: all + roles: + - { role: ansible-datadog, become: yes } + vars: + datadog_agent6: true \ No newline at end of file diff --git a/tests/test_6_full.yml b/tests/test_6_full.yml new file mode 100644 index 00000000..e4a231d2 --- /dev/null +++ b/tests/test_6_full.yml @@ -0,0 +1,66 @@ +- hosts: all + roles: + - { role: ansible-datadog, become: yes } # On Ansible < 1.9, use `sudo: yes` instead of `become: yes` + vars: + datadog_agent6: true + datadog_api_key: "123456" + datadog_agent_allow_downgrade: true + datadog_config: + tags: "mytag0, mytag1" + log_level: INFO + apm_enabled: "true" # has to be set as a string + # logs related config + log_enabled: true + logset: main + datadog_config_ex: + trace.config: + env: dev + trace.concentrator: + extra_aggregators: version + datadog_checks: + process: + init_config: + instances: + - name: ssh + search_string: ['ssh', 'sshd' ] + - name: syslog + search_string: ['rsyslog' ] + cpu_check_interval: 0.2 + exact_match: true + ignore_denied_access: true + ssh_check: + init_config: + instances: + - host: localhost + port: 22 + username: root + password: changeme + sftp_check: True + private_key_file: + add_missing_keys: True + nginx: + init_config: + instances: + - nginx_status_url: http://example.com/nginx_status/ + tags: + - instance:foo + - nginx_status_url: http://example2.com:1234/nginx_status/ + tags: + - instance:bar + logs: + - type: file + path: /var/log/nginx.log + service: nginx + source: nginx + sourcecategory: webapp + tags: env:prod + - type: tcp + port: 10514 + service: webapp + source: php + sourcecategory: front + log_processing_rules: + - type: exclude_at_match + name: exclude_datadoghq_users + # Regexp can be anything + pattern: User=\w+@datadoghq.com