Re: [ansible-project] Add Servers to Server Manager using PowerShell
I have no experience whatsoever with windows modules, but this looks pretty clear to me: "message": "Cannot find path > 'C:\\Users\\Amitabh.Ghosh\\AppData\\Roaming\\Microsoft\\Windows\\ServerManager\\ServerList.xml' > because it does not exist.", Perhaps an escaping issue? According to https://docs.ansible.com/ansible/latest/os_guide/windows_usage.html when yaml code is not quoted (like in your situation) the backslash does not need to be escaped. Try without the double escapes: script: | try { Get-Process | Where-Object {$_.ProcessName -eq "ServerManager.exe"} | Stop-Process -Force $file = Get-Item "$env:USERPROFILE\AppData\Roaming\\Microsoft\Windows\ServerManager\ServerList.xml" -- Sent from Gmail Mobile -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAF8BbLYvhXaMo%2B5qb07A8B7tODjonkmQ7z2UVXF0MSyLwbziwg%40mail.gmail.com.
Re: [ansible-project] Lineinfile - Skip/Update an item inside "with_items" using conditions
On Wed, 21 Dec 2022 16:30:03 +0500 farrukh ahmed wrote: > 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 *marker* must be unique for each block. Otherwise the the blocks will overwrite each other. For this purpose it would be practical to change the structure of the iterated data. For example, the simplified playbook below shell> cat pb.yml - hosts: localhost tasks: - blockinfile: path: /tmp/test.ini marker: "# {mark} {{ item.param }}" block: | {{ item.param }} = {{ item.value }} loop: - param: 'display_errors' value: "{{ conf.errors }}" - param: 'memory_limit' value: "{{ conf.limit }}" shell> ansible-playbook pb.yml -e '{"conf":{"errors":"On","limit":"128"}}' works as expected and creates the file shell> cat /tmp/test.ini # BEGIN display_errors display_errors = On # END display_errors # BEGIN memory_limit memory_limit = 128 # END memory_limit Fit the data and *marker* to your needs. -- Vladimir Botka -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20221221161421.22127660%40gmail.com. pgpcmZo_YKoO_.pgp Description: OpenPGP digital signature
Re: [ansible-project] Lineinfile - Skip/Update an item inside "with_items" using conditions
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 wrote: > Hii > > On Tue, 20 Dec 2022 at 12:47, farrukh ahmed > 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 > ansible-project+unsubscr...@googlegroups.com. > 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL6Xq1eVr_fvVb5vh76P%2B1G3xPM_fqb1bCzTwcUDbdQHb5WQfQ%40mail.gmail.com.