Is your feature request related to a problem? Please describe
When installing NGINX Amplify via this role, /etc/amplify-agent/agent.conf is always replaced by /etc/amplify-agent/agent.conf.default, regardless of whether this is necessary or not, which makes the role always return changed ansible tasks, even if no change should happen.
Describe the solution you'd like
When the target server is in the desired state, ansible should return changed=0.
Describe alternatives you've considered
I am definitely not an ansible expert and I am sure there are better ways to address this issue, but what I would personally do is split the task:
- name: Check if NGINX Amplify config file template has changed
ansible.builtin.copy:
remote_src: true
src: /etc/amplify-agent/agent.conf.default
dest: /etc/amplify-agent/agent.conf.current
mode: "0644"
register: nginx_amplify_config_template
- name: Replace NGINX Amplify config file only if the template changed
ansible.builtin.copy:
remote_src: true
src: /etc/amplify-agent/agent.conf.current
dest: /etc/amplify-agent/agent.conf
mode: "0644"
when: nginx_amplify_config_template.changed
Additional context
The behaviour above is even more problematic when the agent configuration file is further edited by subsequent tasks, for example when monitoring MySQL. In fact, all customisations to agent.conf must be reapplied with each ansible run.
Is your feature request related to a problem? Please describe
When installing NGINX Amplify via this role,
/etc/amplify-agent/agent.conf
is always replaced by/etc/amplify-agent/agent.conf.default
, regardless of whether this is necessary or not, which makes the role always returnchanged
ansible tasks, even if no change should happen.Describe the solution you'd like
When the target server is in the desired state, ansible should return
changed=0
.Describe alternatives you've considered
I am definitely not an ansible expert and I am sure there are better ways to address this issue, but what I would personally do is split the task:
into:
Additional context
The behaviour above is even more problematic when the agent configuration file is further edited by subsequent tasks, for example when monitoring MySQL. In fact, all customisations to
agent.conf
must be reapplied with each ansible run.