Skip to content

Commit

Permalink
Allow pinning the version of the Agent (#61)
Browse files Browse the repository at this point in the history
And encourage users to pin the version.

By default we still auto-upgrade the agent
(preserves the current behavior), let's change this default
in the next major release of the role.
  • Loading branch information
olivielpeau authored Apr 4, 2017
1 parent 86e0201 commit 4d5b6d2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Role Variables
--------------

- `datadog_api_key` - Your Datadog API key.
- `datadog_agent_version` - The pinned version of the Agent to install (optional, but highly recommended)
Examples: `1:5.12.3-1` on apt-based platforms, `5.12.3-1` on yum-based platforms
- `datadog_checks` - YAML configuration for agent checks to drop into `/etc/dd-agent/conf.d`.
- `datadog_config` - Settings to place in the `/etc/dd-agent/datadog.conf` INI file that go under the `[Main]` section.
- `datadog_config_ex` - Extra INI sections to go in `/etc/dd-agent/datadog.conf` (optional).
Expand All @@ -25,6 +27,7 @@ Role Variables
- `datadog_apt_repo` - Override default Datadog `apt` repository
- `datadog_apt_key_url` - Override default url to Datadog `apt` key
- `datadog_apt_key_url_new` - Override default url to the new Datadog `apt` key (in the near future the `apt` repo will have to be checked against this new key instead of the current key)
- `datadog_allow_agent_downgrade` - Set to `yes` to allow agent downgrades on apt-based platforms (use with caution, see `defaults/main.yml` for details)

Dependencies
------------
Expand All @@ -38,6 +41,7 @@ Example Playbooks
- { role: Datadog.datadog, become: yes } # On Ansible < 1.9, use `sudo: yes` instead of `become: yes`
vars:
datadog_api_key: "123456"
datadog_agent_version: "1:5.12.3-1" # for apt-based platforms, use a `5.12.3-1` format on yum-based platforms
datadog_config:
tags: "mytag0, mytag1"
log_level: INFO
Expand Down
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ datadog_group: root

# default apt repo
datadog_apt_repo: "deb http://apt.datadoghq.com/ stable main"

# Pin agent to a version. Highly recommended.
datadog_agent_version: ""

# Set this to `yes` to allow agent downgrades on apt-based platforms.
# Internally, this uses `apt-get`'s `--force-yes` option. Use with caution.
datadog_agent_allow_downgrade: no
12 changes: 11 additions & 1 deletion tasks/pkg-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,15 @@
- name: Ensure Datadog repository is up-to-date
apt_repository: repo='{{ datadog_apt_repo }}' state=present update_cache=yes

- name: Ensure pinned version of Datadog agent is installed
apt:
name: datadog-agent={{ datadog_agent_version }}
state: present
force: "{{ datadog_agent_allow_downgrade }}"
when: datadog_agent_version != ""

- name: Ensure Datadog agent is installed
apt: name=datadog-agent state=latest
apt:
name: datadog-agent
state: latest
when: datadog_agent_version == ""
13 changes: 11 additions & 2 deletions tasks/pkg-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@
- name: Copy repo file into place
template: src=datadog.repo.j2 dest=/etc/yum.repos.d/datadog.repo owner=root group=root mode=0644

- name: Install datadog-agent package
yum: name=datadog-agent state=latest
- name: Install pinned datadog-agent package
yum:
name: datadog-agent-{{ datadog_agent_version }}
state: present
when: datadog_agent_version != ""

- name: Install latest datadog-agent package
yum:
name: datadog-agent
state: latest
when: datadog_agent_version == ""

0 comments on commit 4d5b6d2

Please sign in to comment.