]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
Allow partial defaults overrides
authorZack Cerza <zack@redhat.com>
Thu, 20 Jul 2017 23:18:58 +0000 (16:18 -0700)
committerZack Cerza <zack@redhat.com>
Thu, 20 Jul 2017 23:35:41 +0000 (16:35 -0700)
With this change, it becomes possible to override certain keys in each configuration dict while accepting the default values for other keys.

Signed-off-by: Zack Cerza <zack@redhat.com>
ansible/roles/ceph-grafana/defaults/main.yml
ansible/roles/ceph-grafana/tasks/main.yml
ansible/roles/ceph-grafana/tasks/merge_vars.yml [new file with mode: 0644]

index b1d6ea5b2ea1e34cfed7d171ea9847c5152a5cf9..7014cf4e8172884930bf7a1a3638360dcfc2a242 100644 (file)
@@ -1,53 +1,54 @@
 ---
-containerized_deployment: false
-use_epel: false
-devel_mode: true
-replace_dashboards: true
-graphite:
-  service: "{{ 'graphite-web' if ansible_pkg_mgr == 'yum' else 'graphite-api' }}"
-  web_port: "{{ graphite_port | default('8080') }}"
-  api_port: 8888
-  user: admin
-  password: admin
-  # The unix account running the graphite-web process
-  unix_user:
-    yum: apache
-    apt: _graphite
-grafana:
-  datasource: Local
-carbon:
-  unix_user:
-    yum: carbon
-    apt: _graphite
-  storage_dir:
-    yum: /var/lib/carbon
-    apt: /var/lib/graphite
-whisper:
-  retention:
-    - ['10s', '7d']
-    - ['1m', '30d']
-    - ['15m', '5y']
-# The firewalld zone that carbon and grafana will use
-firewalld_zone: public
-# RHEL repos that need to be enabled with subscription-manager
-rhsm_repos:
-  - rhel-7-server-rhscon-2-installer-rpms
-  - rhel-7-server-optional-rpms
-devel_packages:
-  yum:
-    # unzip is needed to extract the Vonage plugin
-    - unzip
-    - graphite-web
-    - python-carbon
-    - grafana
-  apt:
-    # unzip is needed to extract the Vonage plugin
-    - unzip
-    - graphite-api
-    # For graphite-api
-    - gunicorn3
-    - graphite-carbon
-    - grafana
-    # for dashUpdater.py
-    - python-yaml
-    - python-requests
+defaults:
+  containerized_deployment: false
+  use_epel: false
+  devel_mode: true
+  replace_dashboards: true
+  grafana:
+    datasource: Local
+  graphite:
+    service: "{{ 'graphite-web' if ansible_pkg_mgr == 'yum' else 'graphite-api' }}"
+    web_port: "{{ graphite_port | default('8080') }}"
+    api_port: 8888
+    user: admin
+    password: admin
+    # The unix account running the graphite-web process
+    unix_user:
+      yum: apache
+      apt: _graphite
+  carbon:
+    unix_user:
+      yum: carbon
+      apt: _graphite
+    storage_dir:
+      yum: /var/lib/carbon
+      apt: /var/lib/graphite
+  whisper:
+    retention:
+      - ['10s', '7d']
+      - ['1m', '30d']
+      - ['15m', '5y']
+  # The firewalld zone that carbon and grafana will use
+  firewalld_zone: public
+  # RHEL repos that need to be enabled with subscription-manager
+  rhsm_repos:
+    - rhel-7-server-rhscon-2-installer-rpms
+    - rhel-7-server-optional-rpms
+  devel_packages:
+    yum:
+      # unzip is needed to extract the Vonage plugin
+      - unzip
+      - graphite-web
+      - python-carbon
+      - grafana
+    apt:
+      # unzip is needed to extract the Vonage plugin
+      - unzip
+      - graphite-api
+      # For graphite-api
+      - gunicorn3
+      - graphite-carbon
+      - grafana
+      # for dashUpdater.py
+      - python-yaml
+      - python-requests
index 85e8ddb385b0dc686b1ab7a1c1657b49951b7d3b..3402bdf8fd0f4cdc0517c4453fed461815d624a4 100644 (file)
@@ -1,4 +1,8 @@
 ---
+- include: merge_vars.yml
+  tags:
+    - always
+
 - include: setup_repos.yml
   when:
     - not containerized_deployment
diff --git a/ansible/roles/ceph-grafana/tasks/merge_vars.yml b/ansible/roles/ceph-grafana/tasks/merge_vars.yml
new file mode 100644 (file)
index 0000000..649ebf1
--- /dev/null
@@ -0,0 +1,5 @@
+---
+- name: Combine default settings and user-defined variables
+  set_fact: {"{{ item }}": "{% if vars[item] is not defined %}{{ defaults[item] }}{% endif %}{% if vars[item] is mapping %}{{ defaults[item]|combine(vars[item]|default({})) }}{% endif %}"}
+  with_items: "{{ defaults.keys() }}"
+  no_log: true