Skip to content

Commit

Permalink
Add epicli versioning (hitachienergy#1306)
Browse files Browse the repository at this point in the history
* Add version info file creation for each VM used.
  • Loading branch information
sbbroot committed Nov 5, 2021
1 parent cab6718 commit a5fd707
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG-1.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Changelog 1.3

## [1.3.0] YYYY-MM-DD

### 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

### Fixed

- [#2497](https://github.com/epiphany-platform/epiphany/issues/2497) - Fix epicli apply --full region values
- [#1743](https://github.com/epiphany-platform/epiphany/issues/1743) - Virtual machine "kind" mismatch

### Updated

- [#2494](https://github.com/epiphany-platform/epiphany/issues/2494) - Duplicated MOTD after ssh to servers

### Deprecated

### Breaking changes

### Known issues
10 changes: 7 additions & 3 deletions cli/engine/ansible/AnsibleCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ def run_task_with_retries(self, inventory, module, hosts, retries, timeout=10, a
else:
raise Exception(f'Failed running task after {str(retries)} retries')

def run_playbook(self, inventory, playbook_path, vault_file=None):
def run_playbook(self, inventory, playbook_path, vault_file=None, extra_vars=None):
cmd = ['ansible-playbook']

if inventory is not None and len(inventory) > 0:
cmd.extend(["-i", inventory])
cmd.extend(['-i', inventory])

if vault_file is not None:
cmd.extend(["--vault-password-file", vault_file])
cmd.extend(['--vault-password-file', vault_file])

if extra_vars is not None:
variables = ' '.join([f"{variable}='{value}'" for variable, value in extra_vars.items()])
cmd.extend(['--extra-vars', variables])

cmd.append(playbook_path)

Expand Down
16 changes: 16 additions & 0 deletions cli/engine/ansible/AnsibleRunner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import datetime
import os
import shutil
import time

from cli.engine.ansible.AnsibleCommand import AnsibleCommand
Expand All @@ -13,6 +15,7 @@
from cli.helpers.naming_helpers import to_role_name
from cli.helpers.data_loader import BASE_DIR, types
from cli.helpers.Config import Config
from cli.version import VERSION


class AnsibleRunner(Step):
Expand Down Expand Up @@ -120,6 +123,13 @@ def apply(self):
# pre-flight to prepare machines
self.pre_flight(inventory_path)

self.ansible_command.run_playbook(inventory=inventory_path,
playbook_path=self.playbook_path(to_role_name('versioning')),
vault_file=Config().vault_password_location,
extra_vars={'mode': 'apply',
'date': datetime.datetime.now().ctime(),
'version': VERSION})

# run roles
enabled_roles = inventory_creator.get_enabled_roles()
for role in enabled_roles:
Expand Down Expand Up @@ -151,6 +161,12 @@ def upgrade(self):
# pre-flight to prepare machines
self.pre_flight(inventory_path)

self.ansible_command.run_playbook(inventory=inventory_path,
playbook_path=self.playbook_path(to_role_name('versioning')),
extra_vars={'mode': 'upgrade',
'date': datetime.datetime.now().ctime(),
'version': VERSION})

# run image_registry playbook
self.ansible_command.run_playbook(inventory=inventory_path,
playbook_path=self.playbook_path('image_registry'))
Expand Down

0 comments on commit a5fd707

Please sign in to comment.