Skip to content

Commit

Permalink
add "Make a list of the RELEASE macros" NOT GOOD USE of ansible!
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Mar 10, 2025
1 parent e9dc0ee commit e17fda5
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
4 changes: 4 additions & 0 deletions _ansible/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# paths
epics_folder: /epics
support_folder: /epics/support
configure_folder: "{{support_folder}}/configure"
modules_file: "{{configure_folder}}/MODULES"
release_file: "{{configure_folder}}/RELEASE"
release_shell_file: "{{configure_folder}}/RELEASE.shell"
rutime_folder: /epics/runtime
ibek_defs_folder: /epics/ibek_defs
autosave_folder: /epics/autosave
2 changes: 1 addition & 1 deletion _ansible/roles/support/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- name: Setup Configure/RELEASE
ansible.builtin.include_tasks: release.yml
tags: [configure]
tags: [release]

- name: Build
ansible.builtin.include_tasks: build.yml
Expand Down
71 changes: 67 additions & 4 deletions _ansible/roles/support/tasks/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

create: true
mode: "0644"
tags: [release]

- name: Add this module to the global configure/RELEASE
ansible.builtin.lineinfile:
Expand All @@ -15,10 +16,72 @@
line: "{{ macro }} = {{ local_path }}"
create: true
mode: "0644"
tags: [release]

- name: Make a list of the RELEASE macros (because a list is ordered)
# slightly stretching fair use of ansible here :-)
tags: [release]
block:
- name: Read the RELEASE file
ansible.builtin.copy:
src: "{{ release_file }}"
dest: /tmp/release
mode: "0644"

# - name: Remove unwanted Macros from global configure/RELEASE
- name: Remove non macro lines
ansible.builtin.lineinfile:
path: "{{ release_file }}"
dest: /tmp/release
# remove lines lines without '='
regexp: "^[^=]*$"
state: absent

- name: Create a dictionary for each support module
ansible.builtin.replace:
path: /tmp/release
# look for lines with '=' not starting with # and make them a dictionary
regexp: "^(?!#)(.*) *= *(.*)$"
replace: "- macro: \\1\n path: \\2"

- name: Insert the root key
ansible.builtin.lineinfile:
path: /tmp/release
line: "release:"
insertbefore: BOF

- name: Load the RELEASE file
ansible.builtin.include_vars:
file: /tmp/release
name: release

- name: Trim extra keys
ansible.builtin.set_fact:
releases: "{{ release.release }}"

- name: Debug
ansible.builtin.debug:
var: releases

- name: Make the RELEASE.shell file
ansible.builtin.lineinfile:
path: "{{ release_shell_file }}"
mode: "0644"
line: "export {{ item.macro }}=\"{{ item.path }}\""
regexp: "export *{{ item.macro }} *=.*$"
loop: "{{ releases }}"
tags: [release]

- name: Add EPICS_DB_INCLUDE_PATH to RELEASE.shell file
ansible.builtin.lineinfile:
path: "{{ release_shell_file }}"
mode: "0644"
line: "export {{ item.macro }}=\"{{ item.path }}\""
regexp: "export *{{ item.macro }} *=.*$"
loop: "{{ releases }}"
tags: [release]

# TODO this one is harder as required running map functions over the list
# but in truth we never use this file (it is for the root Makefile which I never use)
# - name: Make the MODULES file
# ansible.builtin.lineinfile:
# path: "{{ support_folder }}/configure/RELEASE"
# regexp: "^{{ item }}.*=.*"
# line: "{{ item }} ="

8 changes: 7 additions & 1 deletion ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ if [[ -n $module_version ]]; then
vers="-e version=${module_version}"
fi

if [[ $ANSIBLE_TAGS ]]; then
tags=" --tags ${ANSIBLE_TAGS}"
echo "limiting ansible run to tags: ${ANSIBLE_TAGS}"
fi

this_dir=$(dirname $0)
cd $this_dir

Expand All @@ -20,5 +25,6 @@ path=${module_name}/${module_name}.yml
ansible-playbook \
_ansible/support_playbook.yml \
-i _ansible/hosts.yml \
-e @${path} ${vers}
-e @${path} ${vers} \
${tags}

0 comments on commit e17fda5

Please # to comment.