Skip to content

Commit

Permalink
Add epicli versioning (#1306) (#2650)
Browse files Browse the repository at this point in the history
* Add epicli versioning (#1306)

Co-authored-by: to-bar <[email protected]>
  • Loading branch information
sbbroot and to-bar authored Nov 15, 2021
1 parent f2bdadb commit 578b3a0
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
28 changes: 28 additions & 0 deletions ansible/playbooks/postflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,31 @@
become_method: sudo
roles:
- postflight

- name: Update status in epicli execution history file
hosts: all
gather_facts: false
become: true
become_method: sudo
tasks:
- name: Load the history file
slurp:
src: /var/lib/epiphany/history.yml
register: history_file

- name: Parse history file and update the status
set_fact:
history_latest_entry: >-
{{ _history_file_yaml.deployments[0] | combine({'status': 'completed'})}}
history_other_entries: >-
{{ _history_file_yaml.deployments[1:] }}
vars:
_history_file_yaml: "{{ history_file.content | b64decode | from_yaml }}"

- name: Save updated history to file
copy:
content: "{{ _new_content | to_nice_yaml(indent=2) }}"
dest: /var/lib/epiphany/history.yml
vars:
_new_content:
deployments: "{{ [history_latest_entry] + history_other_entries }}"
60 changes: 59 additions & 1 deletion ansible/playbooks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Ansible playbook that checks if requirements are met

- hosts: all
gather_facts: yes
gather_facts: true
become: false # user may be not added to sudoers
module_defaults:
shell:
Expand All @@ -11,3 +11,61 @@
- preflight
environment:
KUBECONFIG: "{{ kubeconfig.remote }}"

- name: Add entry to epicli execution history on each host
hosts: all
gather_facts: true
become: true
become_method: sudo
vars:
history_latest_entry: {}
history_other_entries: []
history_new_entry:
version: "{{ epiphany_version }}"
date: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}"
mode: "{{ is_upgrade_run | ternary('upgrade', 'apply') }}"
status: started
tasks:
- name: Create epiphany directory if it does not exist
file:
path: /var/lib/epiphany
state: directory
mode: u=rwx,go=rx

- name: Get history file status
stat:
path: /var/lib/epiphany/history.yml
register: history_file

- name: Parse history file
when:
- history_file.stat.exists
- history_file.stat.size > 0
block:
- name: Load history file
slurp:
src: /var/lib/epiphany/history.yml
register: history_file_handler

- name: Parse history file
set_fact:
history_latest_entry: "{{ _history_file_yaml.deployments[0] }}"
history_other_entries: "{{ _history_file_yaml.deployments[1:] }}"
vars:
_history_file_yaml: "{{ history_file_handler.content | b64decode | from_yaml }}"

- name: Check previous status and update if needed
set_fact:
history_latest_entry: "{{ history_latest_entry | combine({'status': 'failed'}) }}"
when:
- history_latest_entry.status is defined
- history_latest_entry.status != 'completed'

- name: Update history and save to file
copy:
content: "{{ _new_content | to_nice_yaml(indent=2) }}"
dest: /var/lib/epiphany/history.yml
vars:
_new_content:
deployments: >-
{{ [history_new_entry] + history_latest_entry | ternary([history_latest_entry], []) + history_other_entries }}
1 change: 1 addition & 0 deletions cli/engine/ansible/AnsibleVarsGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def populate_group_vars(self, ansible_dir):
main_vars['is_upgrade_run'] = self.is_upgrade_run
main_vars['roles_with_generated_vars'] = sorted(self.roles_with_generated_vars)
main_vars['upgrade_components'] = Config().upgrade_components
main_vars['epiphany_version'] = VERSION

# Consider to move this to the provider level.
if self.cluster_model.provider != 'any':
Expand Down
1 change: 1 addition & 0 deletions docs/changelogs/CHANGELOG-1.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- [#1306](https://github.com/epiphany-platform/epiphany/issues/1306) - Allow to check on VMs which epicli version was used to deploy/upgrade components
- [#1487](https://github.com//epiphany-platform/epiphany/issues/1487) - Add RabbitMQ monitoring
- [#2600](https://github.com/epiphany-platform/epiphany/issues/2600) - Change epicli output structure
- [#2655](https://github.com/epiphany-platform/epiphany/issues/2655) - Add 'repmgr node check' to upgrade preflight checks and auto-tests
Expand Down

0 comments on commit 578b3a0

Please sign in to comment.