Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create playbook to update allsearch banner #5463

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
44 changes: 44 additions & 0 deletions playbooks/allsearch_banner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# by default this playbook runs in the staging environment
# to run in production, pass '-e runtime_env=production'
- name: change the Allsearch banner
# hosts: allsearch_api_{{ runtime_env | default('staging') }}
hosts: localhost
remote_user: deploy
vars:
- passenger_root: "/opt/allsearch_api/current"
- text_no_comma: "dog cat"
# - text_escaped_comma: "dog\, cat"
- text_unescaped_comma: "dog, cat"
vars_files:
- ../group_vars/allsearch_api/vault.yml
- ../group_vars/allsearch_api/common.yml
- ../group_vars/allsearch_api/{{ runtime_env | default('staging') }}.yml

tasks:
- name: Check the text for commas
ansible.builtin.set_fact:
first_fact: "{{ text_unescaped_comma | regex_replace('?<!\\,', 'commanext,') }}"
# the regex (?<!\\), matches any unescaped comma (,)
# example filter {{ 'ansible' | regex_replace('^a.*i(.*)$', 'a\\1') }} returns able

- name: Show me first_fact
ansible.builtin.debug:
var: first_fact

# - name: Escape unescaped commas
# ansible.builtin.set_fact:
# first_fact: "{{ text_unescaped_comma | regex_replace(?<!\\) }}"

# - name: Run the Rake task
# ansible.builtin.shell: "cd {{ passenger_root }} && /usr/bin/bash --login -c 'RAILS_ENV={{ rails_env | default('staging') }} bundle exec rake banner:update['{{ banner_text }}',{{alert_status | default('info') }},{{dismissible | default('true')}},{{autoclear | default('false')}}]'"
# run_once: true
#bundle exec rake banner:update\['new banner',info,true,true\]
#text,alert_status[info|success|warning|error],dismissible,autoclear

# post_tasks:
# - name: tell everyone on slack you ran an ansible playbook
# community.general.slack:
# token: "{{ vault_pul_slack_token }}"
# msg: "Ansible ran `{{ ansible_play_name }}` on {{ inventory_hostname }}"
# channel: "{{ slack_alerts_channel }}"
Loading