Hello Team,

I have progressed but still not achieved my target with *blockinfile *
module.
It should be updated the both items, as I passed both variables but It just
updated the last item only i.e (memory_limit)

Here is my play:
- name: update php configurations
blockinfile:
path: "{{ini_file_path}}" # set in defaults
marker: ";# {mark} ANSIBLE MANAGED BLOCK ###"
block: "{{ item.param }}"
loop:
- { param: "display_errors = {{service_configurations.display_errors |
d(omit) }}"}
- { param: "memory_limit = {{service_configurations.memory_limit | d(omit)
}}M"}
when: item.param is not search(omit)

The output I'm getting:
;# BEGIN ANSIBLE MANAGED BLOCK ###
memory_limit = 128M
;# END ANSIBLE MANAGED BLOCK ###

The output should be like this, if I passed both variables from the command
line.
;# BEGIN ANSIBLE MANAGED BLOCK ###
display_errors = On
memory_limit = 128M
;# END ANSIBLE MANAGED BLOCK ###

The Command I'm using:
ansible-playbook -i hosts exec.yml -e
'{"service_configurations":{"display_errors":"On","memory_limit":"128"}}'

I would be thankful for any help or ideas.

Thanks.
FARRUKH AHMED

On Tue, Dec 20, 2022 at 5:15 PM Dick Visser <[email protected]> wrote:

> Hii
>
> On Tue, 20 Dec 2022 at 12:47, farrukh ahmed <[email protected]>
> wrote:
> >
> > Can we do the same with blockinfile?
>
> Maybe. But, what one can do, is not always what one should do - see below.
>
> > PS: It is mandatory for me to do this with the blockinfile module.
>
> This is not correct - the file should not be edited at all, because it
> is a package provided file.
> So, any updates will overwrite your changes. Plus you need to resort
> to kludges (imho) like blockinfile.
> What you should do, is put your local changes in a properly named ini
> file below /etc/php/7.4/fpm/conf.d, which won't be touched by anyone
> else.
>
> Dick
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/hBHvqWAmixw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAF8BbLaYD-UTvsx8g0kpC5DMJjxEj4tAj67K-Yw-TMMj4HWhPA%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL6Xq1eVr_fvVb5vh76P%2B1G3xPM_fqb1bCzTwcUDbdQHb5WQfQ%40mail.gmail.com.

Reply via email to