Now I found the community.general.make module. And yes, I could install the plugin with the help of this module. Unfortunately, every time I start the playbook again, it executes the make and make install tasks again.
My understanding for getting the tasks idempotent is to use either creates or a when clause. But both are not allowed with the community.general.make module. So how can I achieve the idempotency?
You could do something like this — only run make and make install if the git clone changes anything or if the /opt/gimp-plugin-bimp/bin/bimp files doesn’t exist?
- name: Clone the BIMP repository
ansible.builtin.git:
repo: https://github.com/alessandrofrancesconi/gimp-plugin-bimp.git
dest: /opt/gimp-plugin-bimp
clone: true
update: true
register: bimp_git_clone
- name: Stat /opt/gimp-plugin-bimp/bin/bimp
ansible.builtin.stat:
path: /opt/gimp-plugin-bimp/bin/bimp
register: bimp_bin_bimp
- name: Build and install BIMP when git clone results change or bin/bimp doesn't exist
block:
- name: Build the BIMP target
community.general.make:
chdir: /opt/gimp-plugin-bimp
- name: Run BIMP 'install' target
community.general.make:
chdir: /opt/gimp-plugin-bimp
target: install
when: ( bimp_git_clone.changed | bool ) or ( not bimp_bin_bimp.stat.exists | bool )
@chris: Thanks for this hint. Unfortunately that does not work. Ansible throws the following exception:
fatal: [xxxxxxx]: FAILED! => {}
MSG:
The conditional check '( bimp_git_clone.changed | bool ) or ( not bimp_bin_bimp.exists | bool )' failed. The error was: error while evaluating conditional (( bimp_git_clone.changed | bool ) or ( not bimp_bin_bimp.exists | bool )): 'dict object' has no attribute 'exists'. 'dict object' has no attribute 'exists'
The error appears to be in '/media/web/projects/common/ansible/runner/project/set_RaspiHOME_example.yml': line 39, column 11, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Build the BIMP target
^ here
Still I think it would be helpful to allow creates in the module.