Skip to content

Commit

Permalink
different approach
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoPlays committed Jun 10, 2024
1 parent cf9c78e commit 0007986
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 67 deletions.
8 changes: 4 additions & 4 deletions controls/roles/update-changes/tasks/2.1.5/sdvt_changes.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Read service file
slurp:
src: "{{ config_file.path }}"
src: "{{ config_file_path }}"
register: service_configuration_raw

- name: Parse service's configuration
Expand All @@ -11,23 +11,23 @@

- name: Adjust Lodestar Config
lineinfile:
path: "{{ config_file.path }}"
path: "{{ config_file_path }}"
regexp: "--useProduceBlockV3"
state: absent
when:
- service_configuration.service == "LodestarValidatorService"

- name: Adjust Teku Config
lineinfile:
path: "{{ config_file.path }}"
path: "{{ config_file_path }}"
regexp: "--Xblock-v3-enabled"
state: absent
when:
- service_configuration.service == "TekuValidatorService"

- name: Adjust Lighthouse Config
lineinfile:
path: "{{ config_file.path }}"
path: "{{ config_file_path }}"
regexp: "--produce-block-v3"
state: absent
when:
Expand Down
91 changes: 28 additions & 63 deletions controls/roles/update-changes/tasks/2.1.5/updates-215.yaml
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

0 comments on commit 0007986

Please sign in to comment.