Skip to content

Instantly share code, notes, and snippets.

@evrardjp
Created April 21, 2018 08:14
Show Gist options
  • Save evrardjp/4837cb5f514f06a0800587bbc4a805a0 to your computer and use it in GitHub Desktop.
Save evrardjp/4837cb5f514f06a0800587bbc4a805a0 to your computer and use it in GitHub Desktop.
Update role files -- old gist written to try a sha bump with ansible
- name: Update role files
hosts: localhost
connection: local
gather_facts: no
vars_files:
- defaults/main.yml
vars:
workdir: "~/evrardjp/test-bump"
project: "nova"
tasks:
# - name: Git clone into temp folder
# git:
# repo: "{{ nova_git_repo }}"
# dest: "{{ workdir }}/{{ project }}"
# version: "{{ nova_git_install_branch }}"
- name: Find api_-paste files
find:
path: "{{ workdir }}/{{ project }}/etc/"
recurse: yes
patterns: '*paste.ini'
register: api_paste_files
- name: Find policy files
find:
path: "{{ workdir }}/{{ project }}/etc/"
recurse: yes
patterns: 'policy.json'
register: policy_files
- name: Find rootwrap files
find:
path: "{{ workdir }}/{{ project }}/etc/"
recurse: yes
patterns: 'rootwrap.conf'
register: rootwrap_files
- name: set facts with real file paths
set_fact:
api_paste_file: "{{ api_paste_files['files'][0]['path'] }}"
when: api_paste_files.matched > 0
- name: set facts with real file paths
set_fact:
policy_file: "{{ policy_files['files'][0]['path'] }}"
when: policy_files.matched > 0
- name: set facts with real file paths
set_fact:
rootwrap_file: "{{ rootwrap_files['files'][0]['path'] }}"
when: rootwrap_files.matched > 0
- name: Find rootwrapd filters
find:
path: "{{ workdir }}/{{ project }}/etc/"
recurse: yes
patterns: '*.filters'
register: rootwrapd_files
- name: Update static files
copy:
src: "{{ item }}"
dest: "{{ playbook_dir }}/templates/{{ item | basename }}.j2"
when: "item is defined"
with_items:
- "{{ api_paste_file }}"
- "{{ policy_file }}"
- "{{ rootwrap_file }}"
- name: Patch files
lineinfile:
path: "{{ item.file }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
backrefs: yes
when: item.when
with_items:
- name: Update barbican profiler hmac
file: "{{ api_paste_file }}"
regexp: 'hmac_keys = (.*)'
line: 'hmac_keys = {% {{ barbican_profiler_hmac_key }} %}'
when: "{{ project }} == barbican"
- name: Add keystoneauth to barbican
file: "{{ api_paste_file }}"
regexp: '/v1: barbican-api-keystone'
line: '/v1: {% raw %}{{ (barbican_keystone_auth | bool) | ternary("barbican-api-keystone", "barbican_api") }}{% endraw %}'
when: "{{ project }} == barbican"
- name: Add keystoneauth to gnocchi
file: "{{ api_paste_file }}"
regexp: 'pipeline = gnocchi+noauth'
line: '{% raw %}pipeline = {{ (gnocchi_keystone_auth | bool) | ternary("gnocchi+auth", "gnocchi+noauth") }}{% endraw %}'
when: "project == 'gnocchi'"
- name: Edit filters path for neutron
file: "{{ playbook_dir }}/templates/rootwrap.conf.j2"
regexp: 'filters_path=/etc/neutron(.*)'
line: 'filters_path={% raw %}{{ neutron_conf_dir }}{% endraw %}\1'
when: "project == 'neutron'"
- name: Edit execution directory in rootwrap.conf
file: "{{ playbook_dir }}/templates/rootwrap.conf.j2"
regexp: 'exec_dirs=(.*)'
line: 'exec_dirs={% raw %}{{ nova_bin }}{% endraw %},\1'
when: True
- name: Update rootwrap filters
copy:
src: "{{ item.path }}"
dest: "{{ playbook_dir }}/files/rootwrap.d/{{ item.path | basename }}"
with_items: "{{ rootwrapd_files['files'] }}"
- name: Update heat files
find:
path: "{{ workdir }}/{{ project }}/etc/"
recurse: yes
patterns: '*.yaml'
register: heat_files
when: "project == 'heat'"
- name: Copy heat files
copy:
src: "{{ item.path }}"
dest: "{{ item.path.replace(workdir ~ project, playbook_dir) }}"
with_items: "{{ heat_files['files'] }}"
when: "project == 'heat'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment