Idempotent configuration commands & config management
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 222
- Forks
- 105
- Avg merge
- 2h 21m
- Merged PRs (30d)
- 1
Description
During our recent ansible configuration of OMERO I had to do some less than desirable things to make it work because some of the configuration can not be done idempotently.
Examples:
When configuring omero.web.ui.top_links it is not possible to use append because this will result in (after multiple runs) repeated entries, so instead it is necessary to use set which necessitates specifying all of the defaults (which could easily change with a new OMERO version).
omero.web.ui.top_links: '[["Data", "webindex", {"title": "Browse Data via Projects, Tags etc"}],["History", "history", {"title": "History"}],["Help", "http://help.openmicroscopy.org/", {"title": "Open OMERO user guide in a new tab", "target": "new"}],["Figure", "figure_index"],["Tag Search", "tagsearch"]]'
I think the best solution to this could be a new command exists for things which are lists.
For the omero.web.ui.top_links example:
omero config exists omero.web.ui.top_links '["Figure", "figure_index"]'
omero config exists omero.web.ui.top_links '["Tag Search", "tagsearch"]'
This one could probably be configured by manipulating XML instead, but as that is not the recommended way to do these changes then I think this makes more sense. Here is another example which could not be done that way though.
Plugin scripts are installed with upload and then replaced with replace. This is fine when doing things manually, but when using config management, it has no way of knowing what to do. If you run upload every time this results in the original script not being replaced. On the flip side, even if the script is already installed, it can't be replaced without some nasty bash foo to get the ID.
- name: check if figure script has been installed (database)
shell: "{{ omero_base }}/OMERO.server/current/bin/omero -u root -w {{ omero_root_password }} -s localhost script list | grep 'Figure_To_Pdf' | gawk -F '|' '{ print $1 }'"
sudo: yes
sudo_user: "{{ omero_user }}"
register: figure_script_id
# Install the figure script (only the first time)
- name: load plugin scripts (first time)
shell: "{{ omero_base }}/OMERO.server/current/bin/omero -u root -w {{ omero_root_password }} -s localhost script upload omero/figure_scripts/Figure_To_Pdf.py --official"
sudo: yes
sudo_user: "{{ omero_user }}"
args:
chdir: "{{ omero_base }}/OMERO.web/current/lib/python/omeroweb/figure/scripts/"
when: figure_script_id.stdout == ""
# Always reinstall the figure script (unless this was the first time)
- name: load plugin scripts (subsequent times)
shell: "{{ omero_base }}/OMERO.server/current/bin/omero -u root -w {{ omero_root_password }} -s localhost script replace {{ figure_script_id.stdout }} omero/figure_scripts/Figure_To_Pdf.py"
sudo: yes
sudo_user: "{{ omero_user }}"
args:
chdir: "{{ omero_base }}/OMERO.web/current/lib/python/omeroweb/figure/scripts/"
when: figure_script_id.stdout != ""
I'm not certain what the best way to fix that one is. Perhaps a command that is not based on ID like replace_or_install_script_at_location or something.
It would be really nice to be able to have any idempotent commands return values be such that config management could determine if something has changed or not.
Finally, if Ansible is what we are all using, then perhaps an action plugin or module could be developed (perhaps making use of underlying idempotent commands with nice return types) so that one could do something like:
- name: Add OMERO.figure to web top links
omero_config:
key: 'omero.web.config.ui.top_links'
value: '["Figure", "figure_index"]'
state: present
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing omero config commands and the omero script upload/replace entry points to understand their current behavior and outputs. Compare these with Ansible's idempotence requirements and determine a focused scope for list updates, script installation, or an Ansible module; done should include reliable changed-state results and repeatable configuration runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ansible
- Domain
- devops, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100