From 5104e4dff422eaa751f2b98a2b93c254c0bf1e09 Mon Sep 17 00:00:00 2001 From: Olivier Vielpeau Date: Mon, 3 Apr 2017 16:30:54 -0400 Subject: [PATCH 1/2] Allow pinning the version of the Agent And encourage users to pin the version. --- README.md | 5 ++++- defaults/main.yml | 7 +++++++ tasks/pkg-debian.yml | 12 +++++++++++- tasks/pkg-redhat.yml | 13 +++++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ed280ea8..4c4dfbcd 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ Role Variables -------------- - `datadog_api_key` - Your Datadog API key. -- `datadog_checks` - YAML configuration for agent checks to drop into `/etc/dd-agent/conf.d`. +- `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). - `datadog_process_checks` - Array of process checks and options (DEPRECATED: use `process` under @@ -25,6 +26,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 ------------ @@ -38,6 +40,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 diff --git a/defaults/main.yml b/defaults/main.yml index 859bfaf4..8efbad2a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/tasks/pkg-debian.yml b/tasks/pkg-debian.yml index 79ff90ff..c20d3db1 100644 --- a/tasks/pkg-debian.yml +++ b/tasks/pkg-debian.yml @@ -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 == "" diff --git a/tasks/pkg-redhat.yml b/tasks/pkg-redhat.yml index 21f421d2..e5d2ae2c 100644 --- a/tasks/pkg-redhat.yml +++ b/tasks/pkg-redhat.yml @@ -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 == "" From 48afef12ae6d344a9e90577e3ac7fe3254ed7076 Mon Sep 17 00:00:00 2001 From: Olivier Vielpeau Date: Tue, 4 Apr 2017 11:28:30 -0400 Subject: [PATCH 2/2] [readme] Fix formatting Addresses review comment [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c4dfbcd..d0e9f1cd 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,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`. + 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). - `datadog_process_checks` - Array of process checks and options (DEPRECATED: use `process` under