From def77f7f7ce63e874b0d15d999b3867c12f7ad09 Mon Sep 17 00:00:00 2001 From: Michal Zielonka Date: Mon, 1 Jun 2015 15:46:10 +0200 Subject: [PATCH 01/28] Add support for RedHat Change-Id: Ifad64c3fe8ed6f6a3e0a51b82a669d020033f147 --- defaults/main.yml | 1 + tasks/apt-packages.yml | 4 ++++ tasks/main.yml | 16 ++++++++++++---- tasks/yum_packages.yml | 4 ++++ templates/monasca-reconfigure.j2 | 2 +- vars/Debian.yml | 7 +++++++ vars/RedHat.yml | 10 ++++++++++ vars/main.yml | 6 ------ 8 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 tasks/apt-packages.yml create mode 100644 tasks/yum_packages.yml create mode 100644 vars/Debian.yml create mode 100644 vars/RedHat.yml diff --git a/defaults/main.yml b/defaults/main.yml index 6d2c2d0..aa49c28 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,6 +3,7 @@ monasca_checks: {} monasca_agent_system_only: False agent_reconfigure_script: /usr/local/bin/monasca-reconfigure monasca_agent_check_frequency: 60 +monasca_agent_version: 1.0.30 skip_install: False monasca_virtualenv_dir: /opt/monasca diff --git a/tasks/apt-packages.yml b/tasks/apt-packages.yml new file mode 100644 index 0000000..a20459a --- /dev/null +++ b/tasks/apt-packages.yml @@ -0,0 +1,4 @@ +- name: Install deps to avoid pip doing compilation or enable it + apt: name={{item}} state=present + with_items: dependencies + when: not skip_install \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index b1fe508..7996895 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,10 +2,18 @@ - include: pip_index.yml when: not skip_install -- name: Install deps to avoid pip doing compilation or enable it - apt: name={{item}} state=present - with_items: dependencies - when: not skip_install +- name: Gather OS Specific Variables + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + - "defaults.yml" + +- include: apt-packages.yml + when: ansible_pkg_mgr == 'apt' +- include: yum_packages.yml + when: ansible_pkg_mgr == 'yum' - name: pip install latest monasca-agent in a virtualenv pip: name=monasca-agent state=latest virtualenv="{{monasca_virtualenv_dir}}" diff --git a/tasks/yum_packages.yml b/tasks/yum_packages.yml new file mode 100644 index 0000000..02ae6c6 --- /dev/null +++ b/tasks/yum_packages.yml @@ -0,0 +1,4 @@ +- name: Install deps to avoid pip doing compilation or enable it + yum: name={{item}} state=present + with_items: dependencies + when: not skip_install \ No newline at end of file diff --git a/templates/monasca-reconfigure.j2 b/templates/monasca-reconfigure.j2 index cd1856f..67c1ccc 100644 --- a/templates/monasca-reconfigure.j2 +++ b/templates/monasca-reconfigure.j2 @@ -1,2 +1,2 @@ #!/bin/sh -{{monasca_virtualenv_dir}}/bin/monasca-setup -u {{monasca_agent_user}} -p {{monasca_agent_password}} {% if monasca_agent_service is defined %} -s {{monasca_agent_service}} {% endif %} --keystone_url {{keystone_url}} --project_name {{monasca_agent_project}} {% if monasca_api_url is defined %} --monasca_url {{monasca_api_url}} {% endif %} {% if monasca_agent_dimensions is defined %} --dimensions {{monasca_agent_dimensions}} {% endif %} --check_frequency {{monasca_agent_check_frequency}} {% if monasca_agent_system_only %} --system_only {% endif %} --overwrite +{{monasca_virtualenv_dir}}/bin/monasca-setup -u {{monasca_agent.user}} -p {{monasca_agent.password}} {% if monasca_agent.service is defined %} -s {{monasca_agent.service}} {% endif %} --keystone_url {{keystone_url}} --project_name {{monasca_agent.project}} {% if monasca_api_url is defined %} --monasca_url {{monasca_api_url}} {% endif %} {% if monasca_agent_dimensions is defined %} --dimensions {{monasca_agent_dimensions}} {% endif %} --check_frequency {{monasca_agent_check_frequency}} {% if monasca_agent_system_only %} --system_only {% endif %} --overwrite diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..9f43e65 --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,7 @@ +--- +dependencies: + - python-dev + - python-yaml + - build-essential + - libxml2-dev + - libxslt1-dev diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..c01b747 --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,10 @@ +--- +dependencies: + - python-devel + - PyYAML + - gcc + - gcc-c++ + - make + - openssl-devel + - libxml2-devel + - libxslt-devel diff --git a/vars/main.yml b/vars/main.yml index 93d8a58..86917c3 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,10 +1,4 @@ --- -dependencies: - - python-dev - - python-yaml - - build-essential - - libxml2-dev - - libxslt1-dev monasca_conf_dir: /etc/monasca monasca_agent_check_plugin_dir: /usr/lib/monasca/agent/custom_checks.d/ monasca_agent_detection_plugin_dir: /usr/lib/monasca/agent/custom_detect.d/ From f010c7ebc59e2ad21393b5240a510ee74cdb68b5 Mon Sep 17 00:00:00 2001 From: Kamil Choroba Date: Wed, 24 Jun 2015 11:33:33 +0200 Subject: [PATCH 02/28] Remove virtualenv usage, because of download problems from other hosts --- tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 7996895..96dd18c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,12 +16,14 @@ when: ansible_pkg_mgr == 'yum' - name: pip install latest monasca-agent in a virtualenv - pip: name=monasca-agent state=latest virtualenv="{{monasca_virtualenv_dir}}" + pip: name=monasca-agent state=latest + #virtualenv="{{monasca_virtualenv_dir}}" notify: run monasca-setup when: not skip_install and monasca_agent_version is not defined - name: pip install a specific version of monasca-agent in a virtualenv - pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{monasca_virtualenv_dir}}" + pip: name=monasca-agent state=present version="{{monasca_agent_version}}" + #virtualenv="{{monasca_virtualenv_dir}}" notify: run monasca-setup when: not skip_install and monasca_agent_version is defined From 48e0ba1d523e0e4d0b7c3042277daf8f38300afc Mon Sep 17 00:00:00 2001 From: Kamil Choroba Date: Wed, 24 Jun 2015 12:23:33 +0200 Subject: [PATCH 03/28] Revert "Remove virtualenv usage, because of download problems from other hosts" This reverts commit f010c7ebc59e2ad21393b5240a510ee74cdb68b5. --- tasks/main.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 96dd18c..7996895 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,14 +16,12 @@ when: ansible_pkg_mgr == 'yum' - name: pip install latest monasca-agent in a virtualenv - pip: name=monasca-agent state=latest - #virtualenv="{{monasca_virtualenv_dir}}" + pip: name=monasca-agent state=latest virtualenv="{{monasca_virtualenv_dir}}" notify: run monasca-setup when: not skip_install and monasca_agent_version is not defined - name: pip install a specific version of monasca-agent in a virtualenv - pip: name=monasca-agent state=present version="{{monasca_agent_version}}" - #virtualenv="{{monasca_virtualenv_dir}}" + pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{monasca_virtualenv_dir}}" notify: run monasca-setup when: not skip_install and monasca_agent_version is defined From 094065831c6f1df99041775295acee3145f55df7 Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Tue, 23 Jun 2015 15:24:26 +0200 Subject: [PATCH 04/28] Change specific version of monasca-agent to be installed This is custom version without pylint requirement Change-Id: Icb500b0ac016e9bfdc7e0044f369b26488d14368 --- defaults/main.yml | 2 +- tasks/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index aa49c28..66b3301 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,7 +3,7 @@ monasca_checks: {} monasca_agent_system_only: False agent_reconfigure_script: /usr/local/bin/monasca-reconfigure monasca_agent_check_frequency: 60 -monasca_agent_version: 1.0.30 +monasca_agent_version: 1.0.31.dev1 skip_install: False monasca_virtualenv_dir: /opt/monasca diff --git a/tasks/main.yml b/tasks/main.yml index 7996895..a5fb7cc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -21,7 +21,7 @@ when: not skip_install and monasca_agent_version is not defined - name: pip install a specific version of monasca-agent in a virtualenv - pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{monasca_virtualenv_dir}}" + pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{monasca_virtualenv_dir}}" extra_args='--pre' notify: run monasca-setup when: not skip_install and monasca_agent_version is defined From 67ba81ddf5e410744af18ba0217a94cbc1958f3a Mon Sep 17 00:00:00 2001 From: bandorf Date: Fri, 26 Jun 2015 11:50:15 +0200 Subject: [PATCH 05/28] Check if pip.conf already exists and skip if true --- tasks/pip_index.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tasks/pip_index.yml b/tasks/pip_index.yml index a6fd3cc..dff9966 100644 --- a/tasks/pip_index.yml +++ b/tasks/pip_index.yml @@ -1,8 +1,11 @@ --- +- stat: path={{ pip_conf_dir }}/pip.conf + register: spc + - name: Create pip conf dir if pip index URL specified file: path={{ pip_conf_dir }} state=directory owner=root group=root mode=770 - when: pip_index_url is defined + when: pip_index_url is defined and not spc.exists - name: Use pip index URL if specified template: dest="{{ pip_conf_dir }}/pip.conf" src=pip.conf.j2 backup=yes owner=root group=root mode=660 - when: pip_index_url is defined + when: pip_index_url is defined and not spc.exists From b0123822fae784aaac6b51e66d6073f234692686 Mon Sep 17 00:00:00 2001 From: Piotr Smialkowski Date: Thu, 30 Jul 2015 16:23:07 +0200 Subject: [PATCH 06/28] Upgrade monasca-agent version: 1.0.31-dev => 1.1.11 --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 66b3301..cdc3f3f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,7 +3,7 @@ monasca_checks: {} monasca_agent_system_only: False agent_reconfigure_script: /usr/local/bin/monasca-reconfigure monasca_agent_check_frequency: 60 -monasca_agent_version: 1.0.31.dev1 +monasca_agent_version: 1.1.11-fix skip_install: False monasca_virtualenv_dir: /opt/monasca From 138b0c9d2c450ad4e96a0292730002544db197bc Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Fri, 31 Jul 2015 13:37:54 +0200 Subject: [PATCH 07/28] Introduce a separate virtualenv directory Change-Id: I537fe762da3cc4f6729a68471bf87c3e7ba9c03d --- defaults/main.yml | 2 +- tasks/main.yml | 4 ++-- templates/monasca-reconfigure.j2 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index cdc3f3f..cc27daf 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,5 +6,5 @@ monasca_agent_check_frequency: 60 monasca_agent_version: 1.1.11-fix skip_install: False -monasca_virtualenv_dir: /opt/monasca +monasca_agent_venv_dir: /opt/venvs/monasca-agent pip_conf_dir: ~/.pip diff --git a/tasks/main.yml b/tasks/main.yml index a5fb7cc..7030312 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,12 +16,12 @@ when: ansible_pkg_mgr == 'yum' - name: pip install latest monasca-agent in a virtualenv - pip: name=monasca-agent state=latest virtualenv="{{monasca_virtualenv_dir}}" + pip: name=monasca-agent state=latest virtualenv="{{ monasca_agent_venv_dir }}" notify: run monasca-setup when: not skip_install and monasca_agent_version is not defined - name: pip install a specific version of monasca-agent in a virtualenv - pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{monasca_virtualenv_dir}}" extra_args='--pre' + pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{ monasca_agent_venv_dir }}" extra_args='--pre' notify: run monasca-setup when: not skip_install and monasca_agent_version is defined diff --git a/templates/monasca-reconfigure.j2 b/templates/monasca-reconfigure.j2 index 67c1ccc..212f686 100644 --- a/templates/monasca-reconfigure.j2 +++ b/templates/monasca-reconfigure.j2 @@ -1,2 +1,2 @@ #!/bin/sh -{{monasca_virtualenv_dir}}/bin/monasca-setup -u {{monasca_agent.user}} -p {{monasca_agent.password}} {% if monasca_agent.service is defined %} -s {{monasca_agent.service}} {% endif %} --keystone_url {{keystone_url}} --project_name {{monasca_agent.project}} {% if monasca_api_url is defined %} --monasca_url {{monasca_api_url}} {% endif %} {% if monasca_agent_dimensions is defined %} --dimensions {{monasca_agent_dimensions}} {% endif %} --check_frequency {{monasca_agent_check_frequency}} {% if monasca_agent_system_only %} --system_only {% endif %} --overwrite +{{ monasca_agent_venv_dir }}/bin/monasca-setup -u {{monasca_agent.user}} -p {{monasca_agent.password}} {% if monasca_agent.service is defined %} -s {{monasca_agent.service}} {% endif %} --keystone_url {{keystone_url}} --project_name {{monasca_agent.project}} {% if monasca_api_url is defined %} --monasca_url {{monasca_api_url}} {% endif %} {% if monasca_agent_dimensions is defined %} --dimensions {{monasca_agent_dimensions}} {% endif %} --check_frequency {{monasca_agent_check_frequency}} {% if monasca_agent_system_only %} --system_only {% endif %} --overwrite From ac22a1562c5ce7fa4aa5d32e457062457277c652 Mon Sep 17 00:00:00 2001 From: Piotr Smialkowski Date: Wed, 5 Aug 2015 10:06:33 +0200 Subject: [PATCH 08/28] Update monasca-agent version: 1.1.12 --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index cdc3f3f..9cc7ce7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,7 +3,7 @@ monasca_checks: {} monasca_agent_system_only: False agent_reconfigure_script: /usr/local/bin/monasca-reconfigure monasca_agent_check_frequency: 60 -monasca_agent_version: 1.1.11-fix +monasca_agent_version: 1.1.12 skip_install: False monasca_virtualenv_dir: /opt/monasca From 5a88a484cc085b823e253418ecfb8116b2413046 Mon Sep 17 00:00:00 2001 From: Witold Bedyk Date: Thu, 6 Aug 2015 14:36:22 +0200 Subject: [PATCH 09/28] Fix bug 11821: change group and permissions of monasca-agent plugin config files --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index a5fb7cc..7991f24 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -33,7 +33,7 @@ - "{{monasca_agent_detection_plugin_dir}}" - name: Create additional plugins config - template: dest="{{monasca_conf_dir}}/agent/conf.d/{{item.key}}.yaml" src=plugin.yaml.j2 owner=root group=root mode=644 + template: dest="{{monasca_conf_dir}}/agent/conf.d/{{item.key}}.yaml" src=plugin.yaml.j2 owner=root group=mon-agent mode=640 with_dict: monasca_checks notify: run monasca-setup From 73b065c74545af6cdaa845fab7e256a8a73edc17 Mon Sep 17 00:00:00 2001 From: Witold Bedyk Date: Fri, 7 Aug 2015 08:45:20 +0200 Subject: [PATCH 10/28] Revert "Fix bug 11821: change group and permissions of monasca-agent plugin config files" This reverts commit 73db978702553a5f6efd33f63f3adef20a4521bc, reversing changes made to 3ea79484f9875b380f7ba70c8bb8aaeb1ca7cb74. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 79f6ca6..7030312 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -33,7 +33,7 @@ - "{{monasca_agent_detection_plugin_dir}}" - name: Create additional plugins config - template: dest="{{monasca_conf_dir}}/agent/conf.d/{{item.key}}.yaml" src=plugin.yaml.j2 owner=root group=mon-agent mode=640 + template: dest="{{monasca_conf_dir}}/agent/conf.d/{{item.key}}.yaml" src=plugin.yaml.j2 owner=root group=root mode=644 with_dict: monasca_checks notify: run monasca-setup From dec6463346e6e86284ed630415e9f6a5028dfd7d Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Thu, 6 Aug 2015 14:57:19 +0200 Subject: [PATCH 11/28] Refactor creating configuration Because monasca-setup handler was run at the end of a playbook, it was overwriting custom 'process' plugin configuration. We had to make ansible assemble configuration from default and provided custom one. This solution is generic and will work also in case of other plugins. Change-Id: I590ba36e618ae82465e10bcdce6d28fb6262bcf5 --- handlers/main.yml | 4 +-- tasks/main.yml | 74 ++++++++++++++++++++++++++++++++++------ templates/plugin.yaml.j2 | 2 +- 3 files changed, 67 insertions(+), 13 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 5a49b2e..99e2150 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,2 +1,2 @@ -- name: run monasca-setup - command: "{{agent_reconfigure_script}}" +- name: restart monasca-agent + service: name=monasca-agent state=restarted enabled=yes diff --git a/tasks/main.yml b/tasks/main.yml index 7030312..dd27e2d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,32 +17,86 @@ - name: pip install latest monasca-agent in a virtualenv pip: name=monasca-agent state=latest virtualenv="{{ monasca_agent_venv_dir }}" - notify: run monasca-setup when: not skip_install and monasca_agent_version is not defined - name: pip install a specific version of monasca-agent in a virtualenv pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{ monasca_agent_venv_dir }}" extra_args='--pre' - notify: run monasca-setup when: not skip_install and monasca_agent_version is defined +# Instead of running this directly by creating a file to run it changes +# such as user/pass will trigger a rerun. Also a user can run it manually +- name: Create reconfigure script + template: + dest="{{agent_reconfigure_script}}" + src=monasca-reconfigure.j2 + owner=root + group=root + mode=750 + tags: + - monasca-agent-config + - name: create conf.d dir and custom plugin dirs file: path="{{item}}" state=directory owner=root group=root mode=755 with_items: - "{{monasca_conf_dir}}/agent/conf.d" - "{{monasca_agent_check_plugin_dir}}" - "{{monasca_agent_detection_plugin_dir}}" + tags: + - monasca-agent-config -- name: Create additional plugins config - template: dest="{{monasca_conf_dir}}/agent/conf.d/{{item.key}}.yaml" src=plugin.yaml.j2 owner=root group=root mode=644 +- name: Run monasca-setup to create all default config files + command: "{{ agent_reconfigure_script }}" + tags: + - monasca-agent-config + +- name: Check for existing plugins configs created by monasca-setup + stat: path="{{ monasca_conf_dir }}/agent/conf.d/{{ item.key }}.yaml" + register: confs + ignore_errors: yes with_dict: monasca_checks - notify: run monasca-setup + tags: + - monasca-agent-config -# Instead of running this directly by creating a file to run it changes such as user/pass will trigger a rerun. Also a user can run it manually -- name: Create reconfigure script - template: dest="{{agent_reconfigure_script}}" src=monasca-reconfigure.j2 owner=root group=root mode=750 - notify: run monasca-setup +- name: Create additional plugins config + template: + dest="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml" + src=plugin.yaml.j2 + owner=root + group=mon-agent + mode=640 + with_items: confs.results + when: not item.stat.exists + tags: + - monasca-agent-config + notify: + - restart monasca-agent + +- name: Create config files fragments for existing configuration + template: + dest="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml.2" + src=plugin.yaml.j2 + owner=root + group=mon-agent + mode=640 + with_items: confs.results + when: item.stat.exists + tags: + - monasca-agent-config -- meta: flush_handlers +- name: Assemble config from fragments + assemble: + src="{{ monasca_conf_dir }}/agent/conf.d/" + dest="{{ monasca_conf_dir }}/agent/conf.d/{{ item.item.key }}.yaml" + regexp="{{ item.item.key }}\.yaml.*" + backup=yes + owner=root + group=mon-agent + mode=640 + with_items: confs.results + tags: + - monasca-agent-config + notify: + - restart monasca-agent - name: Enable Monasca-Agent service: name=monasca-agent state=started enabled=yes diff --git a/templates/plugin.yaml.j2 b/templates/plugin.yaml.j2 index ddd8ae1..b7ae23b 100644 --- a/templates/plugin.yaml.j2 +++ b/templates/plugin.yaml.j2 @@ -1 +1 @@ -{{item.value | to_nice_yaml}} +{{item.item.value | to_nice_yaml}} From fa66d5be9bbb990a5ebb4aae66137d9af7e1fb2d Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Fri, 7 Aug 2015 12:52:31 +0200 Subject: [PATCH 12/28] Add installing psycopg2 for postgres checks Installation is only fired when there's postgres configuration in monasca_checks defined. Change-Id: I62e5c3bd38d526db0bb95295db7e43ee06c920ae --- defaults/main.yml | 2 ++ tasks/main.yml | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index ce8c8b0..632ef4a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -8,3 +8,5 @@ monasca_agent_version: 1.1.12 skip_install: False monasca_agent_venv_dir: /opt/venvs/monasca-agent pip_conf_dir: ~/.pip + +postgresql_dir: diff --git a/tasks/main.yml b/tasks/main.yml index dd27e2d..9136712 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -23,6 +23,16 @@ pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{ monasca_agent_venv_dir }}" extra_args='--pre' when: not skip_install and monasca_agent_version is defined +- name: Install psycopg2 for postgres + pip: name=psycopg2 state=present virtualenv="{{ monasca_agent_venv_dir }}" + environment: + LD_LIBRARY_PATH : "{{ postgresql_dir }}/lib" + PATH: "{{ postgresql_dir }}/bin:{{ ansible_env.PATH }}" + when: monasca_checks.postgres is defined and postgresql_dir + +# TODO: When we introduce mysql checks we would probably add MySQL-Python +# installation here + # Instead of running this directly by creating a file to run it changes # such as user/pass will trigger a rerun. Also a user can run it manually - name: Create reconfigure script From 2fa0e958d99a5ceb647dbd5525f96450848d1948 Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Tue, 11 Aug 2015 15:41:23 +0200 Subject: [PATCH 13/28] Add configurable option for logs directory Change-Id: Iab4a509a68d6d4fca37244edb18cb4b21985bae2 --- defaults/main.yml | 4 ++++ templates/monasca-reconfigure.j2 | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 632ef4a..9c829c9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,6 +5,10 @@ agent_reconfigure_script: /usr/local/bin/monasca-reconfigure monasca_agent_check_frequency: 60 monasca_agent_version: 1.1.12 +log_dir: /var/log +monasca_log_dir: ""{{ log_dir }}/monasca" +monasca_agent_log_dir: "{{ monasca_log_dir }}/agent" + skip_install: False monasca_agent_venv_dir: /opt/venvs/monasca-agent pip_conf_dir: ~/.pip diff --git a/templates/monasca-reconfigure.j2 b/templates/monasca-reconfigure.j2 index 212f686..c056a50 100644 --- a/templates/monasca-reconfigure.j2 +++ b/templates/monasca-reconfigure.j2 @@ -1,2 +1,13 @@ #!/bin/sh -{{ monasca_agent_venv_dir }}/bin/monasca-setup -u {{monasca_agent.user}} -p {{monasca_agent.password}} {% if monasca_agent.service is defined %} -s {{monasca_agent.service}} {% endif %} --keystone_url {{keystone_url}} --project_name {{monasca_agent.project}} {% if monasca_api_url is defined %} --monasca_url {{monasca_api_url}} {% endif %} {% if monasca_agent_dimensions is defined %} --dimensions {{monasca_agent_dimensions}} {% endif %} --check_frequency {{monasca_agent_check_frequency}} {% if monasca_agent_system_only %} --system_only {% endif %} --overwrite +{{ monasca_agent_venv_dir }}/bin/monasca-setup -u {{monasca_agent.user}} \ +-p {{monasca_agent.password}} \ +--log_dir {{ monasca_agent_log_dir }} \ +{% if monasca_agent.service is defined %} -s {{monasca_agent.service}} {% endif %} \ +--keystone_url {{keystone_url}} \ +--project_name {{monasca_agent.project}} \ +{% if monasca_api_url is defined %} --monasca_url {{monasca_api_url}} {% endif %} \ +{% if monasca_agent_dimensions is defined %} --dimensions {{monasca_agent_dimensions}} {% endif %} \ +--check_frequency {{monasca_agent_check_frequency}} \ +{% if monasca_agent_system_only %} --system_only {% endif %} \ +--overwrite +cd From 0a9d9e2b8e10ecff5c824db173bf31c5437f8272 Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Fri, 14 Aug 2015 08:24:01 +0200 Subject: [PATCH 14/28] Fix typo Change-Id: Iddebdedb41fcb41d68265727d44156e5d4fcc647 --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 9c829c9..f3f3d77 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,7 +6,7 @@ monasca_agent_check_frequency: 60 monasca_agent_version: 1.1.12 log_dir: /var/log -monasca_log_dir: ""{{ log_dir }}/monasca" +monasca_log_dir: "{{ log_dir }}/monasca" monasca_agent_log_dir: "{{ monasca_log_dir }}/agent" skip_install: False From b8985ade8574468310b6e597cfbf909690c535d6 Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Fri, 14 Aug 2015 11:42:46 +0200 Subject: [PATCH 15/28] Use more accurate variable for postgresql bin dir Change-Id: If35efa1f079fddbd609071b44d692d5c731c1ba1 --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 9136712..b7052f9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -27,8 +27,8 @@ pip: name=psycopg2 state=present virtualenv="{{ monasca_agent_venv_dir }}" environment: LD_LIBRARY_PATH : "{{ postgresql_dir }}/lib" - PATH: "{{ postgresql_dir }}/bin:{{ ansible_env.PATH }}" - when: monasca_checks.postgres is defined and postgresql_dir + PATH: "{{ postgresql_bin_dir }}:{{ ansible_env.PATH }}" + when: monasca_checks.postgres is defined and postgresql_bin_dir # TODO: When we introduce mysql checks we would probably add MySQL-Python # installation here From 210ab65328ef1a8c251f360a6c09f8b687f93254 Mon Sep 17 00:00:00 2001 From: Michal Zielonka Date: Mon, 1 Jun 2015 15:46:10 +0200 Subject: [PATCH 16/28] Add support for RedHat Change-Id: Ifad64c3fe8ed6f6a3e0a51b82a669d020033f147 --- defaults/main.yml | 10 ++++++- handlers/main.yml | 2 ++ meta/main.yml | 3 ++ tasks/apt-packages.yml | 4 +++ tasks/configure.yml | 59 +++++++++++++++++++++++++++++++++------- tasks/install.yml | 23 ++++++++++++++-- tasks/pip_index.yml | 7 +++-- tasks/yum_packages.yml | 4 +++ templates/plugin.yaml.j2 | 2 +- vars/Debian.yml | 7 +++++ vars/RedHat.yml | 10 +++++++ vars/main.yml | 6 ---- 12 files changed, 114 insertions(+), 23 deletions(-) create mode 100644 tasks/apt-packages.yml create mode 100644 tasks/yum_packages.yml create mode 100644 vars/Debian.yml create mode 100644 vars/RedHat.yml diff --git a/defaults/main.yml b/defaults/main.yml index 119a00b..e6de385 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,8 +4,16 @@ monasca_checks: {} monasca_agent_system_only: False agent_reconfigure_script: /usr/local/bin/monasca-reconfigure +monasca_agent_check_frequency: 60 + +log_dir: /var/log +monasca_log_dir: "{{ log_dir }}/monasca" +monasca_agent_log_dir: "{{ monasca_log_dir }}/agent" skip_install: False -monasca_virtualenv_dir: /opt/monasca +monasca_agent_venv_dir: /opt/monasca-agent pip_conf_dir: ~/.pip + run_mode: Deploy + +postgresql_dir: diff --git a/handlers/main.yml b/handlers/main.yml index 053046d..aabcc82 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,7 @@ --- # ©Copyright 2015 Hewlett-Packard Development Company, L.P. +- name: restart monasca-agent + service: name=monasca-agent state=restarted enabled=yes - name: run monasca-setup command: "{{agent_reconfigure_script}}" diff --git a/meta/main.yml b/meta/main.yml index b171e98..082c5cd 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -9,6 +9,9 @@ galaxy_info: - name: Ubuntu versions: - all + - name: RedHat + versions: + - all categories: - monitoring dependencies: [] diff --git a/tasks/apt-packages.yml b/tasks/apt-packages.yml new file mode 100644 index 0000000..95d87cd --- /dev/null +++ b/tasks/apt-packages.yml @@ -0,0 +1,4 @@ +- name: Install deps to avoid pip doing compilation or enable it + apt: name={{item}} state=present + with_items: dependencies + when: not skip_install diff --git a/tasks/configure.yml b/tasks/configure.yml index 6311fd8..784de0c 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -1,6 +1,14 @@ --- # ©Copyright 2015 Hewlett-Packard Development Company, L.P. +- name: Create reconfigure script + template: + dest="{{agent_reconfigure_script}}" + src=monasca-reconfigure.j2 + owner=root + group=root + mode=750 + - name: create conf.d dir and custom plugin dirs file: path="{{item}}" state=directory owner=root group=root mode=755 with_items: @@ -8,17 +16,48 @@ - "{{monasca_agent_check_plugin_dir}}" - "{{monasca_agent_detection_plugin_dir}}" -- name: Create additional plugins config - template: dest="{{monasca_conf_dir}}/agent/conf.d/{{item.key}}.yaml" src=plugin.yaml.j2 owner=root group=root mode=644 +- name: Run monasca-setup to create all default config files + command: "{{ agent_reconfigure_script }}" + +- name: Check for existing plugins configs created by monasca-setup + stat: path="{{ monasca_conf_dir }}/agent/conf.d/{{ item.key }}.yaml" + register: confs + ignore_errors: yes with_dict: monasca_checks - notify: run monasca-setup -# Instead of running this directly by creating a file to run it changes such as user/pass will trigger a rerun. Also a user can run it manually -- name: Create reconfigure script - template: dest="{{agent_reconfigure_script}}" src=monasca-reconfigure.j2 owner=root group=root mode=750 - notify: run monasca-setup +- name: Create additional plugins config + template: + dest="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml" + src=plugin.yaml.j2 + owner=root + group=mon-agent + mode=640 + with_items: confs.results + when: not item.stat.exists + notify: + - restart monasca-agent -- meta: flush_handlers +- name: Create config files fragments for existing configuration + template: + dest="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml.2" + src=plugin.yaml.j2 + owner=root + group=mon-agent + mode=640 + with_items: confs.results + when: item.stat.exists -- name: Enable Monasca-Agent - service: name=monasca-agent state=started enabled=yes +- name: Assemble config from fragments + assemble: + src="{{ monasca_conf_dir }}/agent/conf.d/" + dest="{{ monasca_conf_dir }}/agent/conf.d/{{ item.item.key }}.yaml" + regexp="{{ item.item.key }}\.yaml.*" + backup=yes + owner=root + group=mon-agent + mode=640 + with_items: confs.results + notify: + - restart monasca-agent + +- meta: flush_handlers diff --git a/tasks/install.yml b/tasks/install.yml index ce21596..00fab80 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -2,10 +2,20 @@ # ©Copyright 2015 Hewlett-Packard Development Company, L.P. - include: pip_index.yml + when: not skip_install -- name: Install deps to avoid pip doing compilation or enable it - apt: name={{item}} state=present - with_items: dependencies +- name: Gather OS Specific Variables + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + - "defaults.yml" + +- include: apt-packages.yml + when: ansible_pkg_mgr == 'apt' +- include: yum_packages.yml + when: ansible_pkg_mgr == 'yum' - name: pip install latest monasca-agent in a virtualenv pip: name=monasca-agent state=latest virtualenv="{{monasca_virtualenv_dir}}" @@ -16,3 +26,10 @@ pip: name=monasca-agent state=present version="{{monasca_agent_version}}" virtualenv="{{monasca_virtualenv_dir}}" notify: run monasca-setup when: monasca_agent_version is defined + +- name: Install psycopg2 for postgres + pip: name=psycopg2 state=present virtualenv="{{ monasca_agent_venv_dir }}" + environment: + LD_LIBRARY_PATH : "{{ postgresql_dir }}/lib" + PATH: "{{ postgresql_bin_dir }}:{{ ansible_env.PATH }}" + when: monasca_checks.postgres is defined and postgresql_bin_dir diff --git a/tasks/pip_index.yml b/tasks/pip_index.yml index f4a5586..70514dc 100644 --- a/tasks/pip_index.yml +++ b/tasks/pip_index.yml @@ -1,10 +1,13 @@ --- # ©Copyright 2015 Hewlett-Packard Development Company, L.P. +- stat: path={{ pip_conf_dir }}/pip.conf + register: spc + - name: Create pip conf dir if pip index URL specified file: path={{ pip_conf_dir }} state=directory owner=root group=root mode=770 - when: pip_index_url is defined + when: pip_index_url is defined and not spc.exists - name: Use pip index URL if specified template: dest="{{ pip_conf_dir }}/pip.conf" src=pip.conf.j2 backup=yes owner=root group=root mode=660 - when: pip_index_url is defined + when: pip_index_url is defined and not spc.exists diff --git a/tasks/yum_packages.yml b/tasks/yum_packages.yml new file mode 100644 index 0000000..2fd121d --- /dev/null +++ b/tasks/yum_packages.yml @@ -0,0 +1,4 @@ +- name: Install deps to avoid pip doing compilation or enable it + yum: name={{item}} state=present + with_items: dependencies + when: not skip_install diff --git a/templates/plugin.yaml.j2 b/templates/plugin.yaml.j2 index ddd8ae1..b7ae23b 100644 --- a/templates/plugin.yaml.j2 +++ b/templates/plugin.yaml.j2 @@ -1 +1 @@ -{{item.value | to_nice_yaml}} +{{item.item.value | to_nice_yaml}} diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..9f43e65 --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,7 @@ +--- +dependencies: + - python-dev + - python-yaml + - build-essential + - libxml2-dev + - libxslt1-dev diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..c01b747 --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,10 @@ +--- +dependencies: + - python-devel + - PyYAML + - gcc + - gcc-c++ + - make + - openssl-devel + - libxml2-devel + - libxslt-devel diff --git a/vars/main.yml b/vars/main.yml index 53757b7..78b77ee 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,12 +1,6 @@ --- # ©Copyright 2015 Hewlett-Packard Development Company, L.P. -dependencies: - - python-dev - - python-yaml - - build-essential - - libxml2-dev - - libxslt1-dev monasca_conf_dir: /etc/monasca monasca_agent_check_plugin_dir: /usr/lib/monasca/agent/custom_checks.d/ monasca_agent_detection_plugin_dir: /usr/lib/monasca/agent/custom_detect.d/ From f4e5e480b51672479e2d66f5161394ba8ae5fa93 Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Fri, 4 Sep 2015 09:22:48 +0200 Subject: [PATCH 17/28] Add flag for overwriting configuration Custom configuration won't be overwritten if you set `monasca_agent_overwrite_config` to True. Change-Id: I30391e73ce08db7ab08043fe221441eaf1f1c6e4 --- defaults/main.yml | 1 + templates/monasca-reconfigure.j2 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index e6de385..2bcddaf 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,6 +3,7 @@ monasca_checks: {} monasca_agent_system_only: False +monasca_agent_overwrite_config: True agent_reconfigure_script: /usr/local/bin/monasca-reconfigure monasca_agent_check_frequency: 60 diff --git a/templates/monasca-reconfigure.j2 b/templates/monasca-reconfigure.j2 index 5c32474..b9482c2 100644 --- a/templates/monasca-reconfigure.j2 +++ b/templates/monasca-reconfigure.j2 @@ -10,4 +10,4 @@ {% if monasca_agent_check_frequency is defined %} --check_frequency '{{monasca_agent_check_frequency}}' {% endif %} \ {% if monasca_agent_system_only %} --system_only {% endif %} \ {% if monasca_log_level is defined %} --log_level '{{monasca_log_level}}' {% endif %} \ - --overwrite + {% if monasca_agent_overwrite_config %} --overwrite{% endif %} From 6a55e1c43b98701a8ad0017d1f8bd8e38d538ec0 Mon Sep 17 00:00:00 2001 From: Lukasz Zajaczkowski Date: Mon, 28 Sep 2015 14:18:32 +0000 Subject: [PATCH 18/28] Add appropriate acess right during monasca-agent installation Change-Id: Ifc3e39763ad2563c7673a6ade7a6c6578268ec50 --- defaults/main.yml | 3 +++ tasks/configure.yml | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 2bcddaf..3435e6c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,3 +18,6 @@ pip_conf_dir: ~/.pip run_mode: Deploy postgresql_dir: + +monasca_agent_system_group: mon-agent +monasca_agent_system_user: mon-agent diff --git a/tasks/configure.yml b/tasks/configure.yml index 784de0c..02cef01 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -1,16 +1,22 @@ --- # ©Copyright 2015 Hewlett-Packard Development Company, L.P. +- name: setup group + group: name={{monasca_agent_system_group}} system=yes + +- name: Setup user + user: name={{monasca_agent_system_user}} system=yes group={{monasca_agent_system_group}} + - name: Create reconfigure script template: dest="{{agent_reconfigure_script}}" src=monasca-reconfigure.j2 - owner=root - group=root + owner={{monasca_agent_system_user}} + group={{monasca_agent_system_group}} mode=750 - name: create conf.d dir and custom plugin dirs - file: path="{{item}}" state=directory owner=root group=root mode=755 + file: path="{{item}}" state=directory owner={{monasca_agent_system_user}} group={{monasca_agent_system_group}} mode=750 with_items: - "{{monasca_conf_dir}}/agent/conf.d" - "{{monasca_agent_check_plugin_dir}}" @@ -29,8 +35,8 @@ template: dest="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml" src=plugin.yaml.j2 - owner=root - group=mon-agent + owner={{monasca_agent_system_user}} + group={{monasca_agent_system_group}} mode=640 with_items: confs.results when: not item.stat.exists @@ -41,8 +47,8 @@ template: dest="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml.2" src=plugin.yaml.j2 - owner=root - group=mon-agent + owner={{monasca_agent_system_user}} + group={{monasca_agent_system_group}} mode=640 with_items: confs.results when: item.stat.exists @@ -53,11 +59,24 @@ dest="{{ monasca_conf_dir }}/agent/conf.d/{{ item.item.key }}.yaml" regexp="{{ item.item.key }}\.yaml.*" backup=yes - owner=root - group=mon-agent + owner={{monasca_agent_system_user}} + group={{monasca_agent_system_group}} mode=640 with_items: confs.results notify: - restart monasca-agent +- name: Set proper attributes of files + file: + path="{{item}}" + state=directory + owner={{monasca_agent_system_user}} + group={{monasca_agent_system_group}} + mode="u+rwX,g+rX,o-rwx" + recurse=yes + with_items: + - "{{monasca_conf_dir}}/agent" + - "{{monasca_agent_log_dir}}" + - "{{monasca_agent_venv_dir}}" + - meta: flush_handlers From 2bb717a5b8a80b5e2973b3d11b8395930d3970e5 Mon Sep 17 00:00:00 2001 From: Lukasz Zajaczkowski Date: Wed, 30 Sep 2015 13:47:28 +0000 Subject: [PATCH 19/28] Add additional group Change-Id: I30b8c82f1066190e8d566d56088dd70eed643d54 --- defaults/main.yml | 1 + tasks/configure.yml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3435e6c..4b0b383 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -21,3 +21,4 @@ postgresql_dir: monasca_agent_system_group: mon-agent monasca_agent_system_user: mon-agent +monasca_group: monasca diff --git a/tasks/configure.yml b/tasks/configure.yml index 02cef01..371eb6d 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -5,7 +5,11 @@ group: name={{monasca_agent_system_group}} system=yes - name: Setup user - user: name={{monasca_agent_system_user}} system=yes group={{monasca_agent_system_group}} + user: + name: "{{ monasca_agent_system_user }}" + system: yes + group: "{{ monasca_agent_system_group }}" + groups: "{{ monasca_group }}" - name: Create reconfigure script template: From 2be19ce3a0d63ce48edaf6d46afa99194bcf72c4 Mon Sep 17 00:00:00 2001 From: Lukasz Zajaczkowski Date: Thu, 1 Oct 2015 07:08:21 +0000 Subject: [PATCH 20/28] Setup groups mon-agent and monasca Change-Id: I640fac670e46820046c821534b65456c0eacde65 --- tasks/configure.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index 371eb6d..8edc9c8 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -1,8 +1,11 @@ --- # ©Copyright 2015 Hewlett-Packard Development Company, L.P. -- name: setup group - group: name={{monasca_agent_system_group}} system=yes +- name: Setup group + group: name="{{item}}" system=yes + with_items: + - "{{monasca_agent_system_group}}" + - "{{ monasca_group }}" - name: Setup user user: @@ -19,7 +22,7 @@ group={{monasca_agent_system_group}} mode=750 -- name: create conf.d dir and custom plugin dirs +- name: Create conf.d dir and custom plugin dirs file: path="{{item}}" state=directory owner={{monasca_agent_system_user}} group={{monasca_agent_system_group}} mode=750 with_items: - "{{monasca_conf_dir}}/agent/conf.d" From 9d413a1852026d1c8469703680fa8b36c1dca81a Mon Sep 17 00:00:00 2001 From: Zawisza Hodzic Date: Mon, 19 Oct 2015 13:59:53 +0200 Subject: [PATCH 21/28] Fixed permissions and cleaned up agent config files Remove config file fragments, prevent backup generation. Moved the task which ensures that proper permissions are set to the bottom so that all files generated by handlers have proper permissions. Change-Id: Iad96ad35e58813e22a660dafaadc98ca1dd56fb8 --- tasks/configure.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index 8edc9c8..a421d79 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -65,7 +65,6 @@ src="{{ monasca_conf_dir }}/agent/conf.d/" dest="{{ monasca_conf_dir }}/agent/conf.d/{{ item.item.key }}.yaml" regexp="{{ item.item.key }}\.yaml.*" - backup=yes owner={{monasca_agent_system_user}} group={{monasca_agent_system_group}} mode=640 @@ -73,6 +72,12 @@ notify: - restart monasca-agent +- name: Remove file fragments + file: path="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml.2" state=absent + with_items: confs.results + +- meta: flush_handlers + - name: Set proper attributes of files file: path="{{item}}" @@ -85,5 +90,3 @@ - "{{monasca_conf_dir}}/agent" - "{{monasca_agent_log_dir}}" - "{{monasca_agent_venv_dir}}" - -- meta: flush_handlers From 0c465fe1d26b7c940384c99d121b46de6fe72e06 Mon Sep 17 00:00:00 2001 From: Michal Zielonka Date: Wed, 4 Nov 2015 11:53:30 +0100 Subject: [PATCH 22/28] Adjusting monasca-agent role - add environment variable for pip task Change-Id: If64a4412f58e5395ac163890ed681a65a109eb7b --- tasks/install.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/install.yml b/tasks/install.yml index 00fab80..391158b 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -30,6 +30,7 @@ - name: Install psycopg2 for postgres pip: name=psycopg2 state=present virtualenv="{{ monasca_agent_venv_dir }}" environment: + PIP_CONFIG_FILE: "{{ pip_config_file }}" LD_LIBRARY_PATH : "{{ postgresql_dir }}/lib" PATH: "{{ postgresql_bin_dir }}:{{ ansible_env.PATH }}" when: monasca_checks.postgres is defined and postgresql_bin_dir From 465293f6a00a22caff11aa17373a1fb1b169d8fe Mon Sep 17 00:00:00 2001 From: Zawisza Hodzic Date: Fri, 29 Jan 2016 14:48:01 +0100 Subject: [PATCH 23/28] Create directory for logs with correct attributes This prevents the problem with the process not starting if it can't write to log files. The situation may occur if the agent is removed along with the system user and then reinstalled. Change-Id: I6a3dd48103829e3f1e0ab5841be1dd5a93446bbf --- tasks/configure.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index a421d79..63945ad 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -29,6 +29,15 @@ - "{{monasca_agent_check_plugin_dir}}" - "{{monasca_agent_detection_plugin_dir}}" +- name: Create log dir + file: + path={{monasca_agent_log_dir}} + state=directory + owner={{monasca_agent_system_user}} + group={{monasca_agent_system_group}} + mode="u+rwX,g+rX,o-rwx" + recurse=yes + - name: Run monasca-setup to create all default config files command: "{{ agent_reconfigure_script }}" @@ -76,8 +85,6 @@ file: path="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml.2" state=absent with_items: confs.results -- meta: flush_handlers - - name: Set proper attributes of files file: path="{{item}}" @@ -90,3 +97,5 @@ - "{{monasca_conf_dir}}/agent" - "{{monasca_agent_log_dir}}" - "{{monasca_agent_venv_dir}}" + +- meta: flush_handlers From d92d1bf001d322eb446c7d0730308adc7294dc92 Mon Sep 17 00:00:00 2001 From: Zawisza Hodzic Date: Wed, 10 Feb 2016 13:35:19 +0100 Subject: [PATCH 24/28] Install psycopg2 only if PostgreSQL binaries exist Change-Id: Ib29cac4e7dbab8049d6a1ee00a3f8916defdb6a1 --- tasks/install.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tasks/install.yml b/tasks/install.yml index 0860cff..3d51e88 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -30,10 +30,15 @@ notify: run monasca-setup when: monasca_agent_version is defined +- name: Check if PostgreSQL binaries are in place + stat: path={{postgresql_bin_dir}} + register: pgsql_bin + when: monasca_checks.postgres is defined + - name: Install psycopg2 for postgres pip: name=psycopg2 state=present virtualenv="{{ monasca_agent_venv_dir }}" environment: PIP_CONFIG_FILE: "{{ pip_config_file }}" LD_LIBRARY_PATH : "{{ postgresql_dir }}/lib" PATH: "{{ postgresql_bin_dir }}:{{ ansible_env.PATH }}" - when: monasca_checks.postgres is defined and postgresql_bin_dir + when: monasca_checks.postgres is defined and pgsql_bin.stat.exists From 0b8f631d13e6697c2a093abf4a720e9c692d13f3 Mon Sep 17 00:00:00 2001 From: Artur Basiak Date: Mon, 4 Apr 2016 08:24:04 +0200 Subject: [PATCH 25/28] Changes for Monasca Mitaka Added installation of extra packages that are required for monasca-agent. Change-Id: I07777044eaffca8e5d1b9107ac6af1d5b8112c8c --- README.md | 1 + defaults/main.yml | 2 ++ tasks/install.yml | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/README.md b/README.md index daecf96..f0332fa 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ virtualenv must be installed on the system. - monasca_log_level: Log level of the agent logs, default is WARN - pip_index_url: Index URL to use instead of the default for installing pip packages - run_mode: One of Deploy, Stop, Install, Start, or Use. The default is Deploy which will do Install, Configure, then Start. 'Use' can be set if the only desire is to use the monasca_agent_plugin module +- pip_extra_depedencies: The list with extra packages that should be installed via pip Optionally supply monasca_checks variable which is a dictionary with each entry consisting of a plugin name followed by the plugin config, typically with two sections init_config and instances. Refer to the specific monasca-agent plugin documentation diff --git a/defaults/main.yml b/defaults/main.yml index 4b0b383..850349c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -22,3 +22,5 @@ postgresql_dir: monasca_agent_system_group: mon-agent monasca_agent_system_user: mon-agent monasca_group: monasca + +pip_extra_depedencies: [] diff --git a/tasks/install.yml b/tasks/install.yml index 3d51e88..638f4da 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -42,3 +42,7 @@ LD_LIBRARY_PATH : "{{ postgresql_dir }}/lib" PATH: "{{ postgresql_bin_dir }}:{{ ansible_env.PATH }}" when: monasca_checks.postgres is defined and pgsql_bin.stat.exists + +- name: Install pip extra depedencies + pip: name="{{item.name}}" state=present version="{{item.version}}" virtualenv="{{monasca_virtualenv_dir}}" + with_items: "{{pip_extra_depedencies}}" From c7f0b3e1db7ff4520b10bc0091f8d5839277476e Mon Sep 17 00:00:00 2001 From: Haruki Yamanashi Date: Sun, 10 Apr 2016 22:55:45 -0400 Subject: [PATCH 26/28] Remove postgresql adapter Remove installing pyscopg2 from task and postgresql_dir from main.yml. Change-Id: I47cf45f607fb0856bc1b7c66a2a90ae5ff3f0d86 --- defaults/main.yml | 2 -- tasks/install.yml | 14 +------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 850349c..66e78a3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,8 +17,6 @@ pip_conf_dir: ~/.pip run_mode: Deploy -postgresql_dir: - monasca_agent_system_group: mon-agent monasca_agent_system_user: mon-agent monasca_group: monasca diff --git a/tasks/install.yml b/tasks/install.yml index 638f4da..3480213 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -30,19 +30,7 @@ notify: run monasca-setup when: monasca_agent_version is defined -- name: Check if PostgreSQL binaries are in place - stat: path={{postgresql_bin_dir}} - register: pgsql_bin - when: monasca_checks.postgres is defined - -- name: Install psycopg2 for postgres - pip: name=psycopg2 state=present virtualenv="{{ monasca_agent_venv_dir }}" - environment: - PIP_CONFIG_FILE: "{{ pip_config_file }}" - LD_LIBRARY_PATH : "{{ postgresql_dir }}/lib" - PATH: "{{ postgresql_bin_dir }}:{{ ansible_env.PATH }}" - when: monasca_checks.postgres is defined and pgsql_bin.stat.exists - name: Install pip extra depedencies pip: name="{{item.name}}" state=present version="{{item.version}}" virtualenv="{{monasca_virtualenv_dir}}" - with_items: "{{pip_extra_depedencies}}" + with_items: "{{pip_extra_depedencies}}" \ No newline at end of file From 80740acd53ff2385f06db3f5cf181cd064ffd741 Mon Sep 17 00:00:00 2001 From: Haruki Yamanashi Date: Thu, 19 May 2016 06:24:26 -0400 Subject: [PATCH 27/28] Change for installation pbr to virtual environment This patch installs pbr into virtual environment to deal with user proxy setting. Change-Id: I0d17ba56ad8b29d88302f7934ee1e5a304a7072c --- defaults/main.yml | 1 + tasks/install.yml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 66e78a3..20a737e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -16,6 +16,7 @@ monasca_agent_venv_dir: /opt/monasca-agent pip_conf_dir: ~/.pip run_mode: Deploy +pbr_version: 1.8.1 monasca_agent_system_group: mon-agent monasca_agent_system_user: mon-agent diff --git a/tasks/install.yml b/tasks/install.yml index 3480213..b6b97a7 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -20,6 +20,10 @@ - name: Upgrade pip in virtualenv pip: name=pip state=latest virtualenv="{{monasca_virtualenv_dir}}" +- name: Install pbr + pip: name=pbr version="{{ pbr_version }}" state=present virtualenv="{{ monasca_virtualenv_dir }}" + when: not skip_install + - name: pip install latest monasca-agent in a virtualenv pip: name=monasca-agent state=latest virtualenv="{{monasca_virtualenv_dir}}" notify: run monasca-setup @@ -33,4 +37,4 @@ - name: Install pip extra depedencies pip: name="{{item.name}}" state=present version="{{item.version}}" virtualenv="{{monasca_virtualenv_dir}}" - with_items: "{{pip_extra_depedencies}}" \ No newline at end of file + with_items: "{{pip_extra_depedencies}}" From c4aa81236f5f19a2490a902de886c2cbb31d3845 Mon Sep 17 00:00:00 2001 From: Zawisza Hodzic Date: Fri, 27 May 2016 15:09:48 +0200 Subject: [PATCH 28/28] Flush handlers before file attributes are set The purpuse of this flush is to trigger monasca-setup before the role sets proper attributes of files. Monasca-setup manipulates configuration files and may change their owner and group to root. Change-Id: I5a4fae31b9ce0e7510a220f0041c6ddfded643b0 --- tasks/configure.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index 63945ad..338985f 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -85,6 +85,8 @@ file: path="{{monasca_conf_dir}}/agent/conf.d/{{item.item.key}}.yaml.2" state=absent with_items: confs.results +- meta: flush_handlers + - name: Set proper attributes of files file: path="{{item}}" @@ -97,5 +99,3 @@ - "{{monasca_conf_dir}}/agent" - "{{monasca_agent_log_dir}}" - "{{monasca_agent_venv_dir}}" - -- meta: flush_handlers