forked from stereum-dev/ethereum-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 28 additions & 63 deletions
91
controls/roles/update-changes/tasks/2.1.5/updates-215.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,42 @@ | ||
--- | ||
- name: Find service configs | ||
find: | ||
paths: "/etc/stereum/services" | ||
register: service_config_files | ||
|
||
- name: Include ValidatorEjector Changes | ||
include_tasks: ValidatorEjector_changes.yaml | ||
loop: "{{ service_config_files.files }}" | ||
|
||
- name: Find potential CharonService files | ||
find: | ||
paths: "/etc/stereum/services" | ||
contains: "service: CharonService" | ||
register: found_files | ||
- name: Filter files that contain both regex patterns | ||
shell: "grep -rlE 'service: CharonService' /etc/stereum/services | xargs grep -lE 'image: obolnetwork/charon:v1\\.[0-9]+\\.[0-9]+'" | ||
register: grep_result | ||
failed_when: false | ||
changed_when: false | ||
|
||
- name: Ensure found_files is not empty | ||
assert: | ||
that: found_files.matched > 0 | ||
fail_msg: "No files found with 'service: CharonService'" | ||
|
||
- name: Read file content | ||
slurp: | ||
src: "{{ item.path }}" | ||
register: file_content | ||
loop: "{{ found_files.files }}" | ||
when: found_files.matched > 0 | ||
|
||
- name: Initialize charon_service_files | ||
- name: Set fact for filtered files | ||
set_fact: | ||
charon_service_files: [] | ||
filtered_files: "{{ grep_result.stdout_lines }}" | ||
|
||
- name: Check for specific image pattern | ||
- name: Extract UUIDs from filtered filenames | ||
set_fact: | ||
charon_service_files: "{{ charon_service_files + [item.source] }}" | ||
loop: "{{ file_content.results }}" | ||
when: > | ||
(item.content | b64decode | search('service: CharonService')) and | ||
(item.content | b64decode | search('image: obolnetwork/charon:v1\\.[0-9]+\\.[0-9]+')) | ||
uuids: "{{ filtered_files | map('basename') | map('regex_replace', '\\.yaml$', '') | list }}" | ||
|
||
- name: Debug CharonService files | ||
debug: | ||
var: charon_service_files | ||
|
||
- name: Set Conditional | ||
set_fact: | ||
charonFound: "{{ charon_service_files.matched | default(0) > 0 }}" | ||
|
||
- name: Set CharonService ID | ||
set_fact: | ||
charon_service_id: "{{ charon_service_files.files[0].path | basename | splitext | first }}" | ||
when: charonFound | ||
|
||
- name: Debug CharonService ID | ||
debug: | ||
var: charon_service_id | ||
when: charonFound | ||
|
||
- name: Find service configs which contain CharonService ID | ||
- name: Find all files in /etc/stereum/services | ||
find: | ||
paths: "/etc/stereum/services" | ||
read_whole_file: true | ||
contains: "{{ charon_service_id }}" | ||
register: charon_service_config_files | ||
when: charonFound | ||
recurse: yes | ||
patterns: "*.yaml" | ||
register: all_files | ||
|
||
- name: Check if files contain any of the extracted UUIDs | ||
shell: "grep -lE '{{ uuids | join('|') }}' {{ item.path }}" | ||
with_items: "{{ all_files.files }}" | ||
register: uuid_grep_result | ||
failed_when: false | ||
changed_when: false | ||
|
||
- name: Set fact for files containing UUIDs | ||
set_fact: | ||
files_with_uuids: "{{ uuid_grep_result.results | selectattr('rc', 'eq', 0) | map(attribute='item.path') | list }}" | ||
|
||
- name: Debug CharonService config files | ||
- name: Debug files with UUIDs | ||
debug: | ||
var: charon_service_config_files | ||
when: charonFound | ||
var: files_with_uuids | ||
|
||
- name: Include SDVT Changes | ||
include_tasks: sdvt_changes.yaml | ||
loop: "{{ charon_service_config_files.files }}" | ||
loop: "{{ files_with_uuids }}" | ||
loop_control: | ||
loop_var: config_file | ||
loop_var: config_file_path | ||
when: charonFound |