Re: [ansible-project] blockinfile help

2023-11-01 Thread Narmada Karthika
oh man, this is awesome it worked like a charm, you saved lot of my time log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'

Re: [ansible-project] blockinfile help

2023-11-01 Thread Todd Lewis
There's the problem, and also why it's so important to include all the relevant details up front. The regexp starts with "^log_format", i.e. it's expecting the 'l' of "log" to be in the first column, but you've got leading white space before "log_format". Change the regexp line thus:        

Re: [ansible-project] blockinfile help

2023-11-01 Thread Narmada Karthika
yes the path is /etc/nginx/nginx.conf, in my earlier email I removed that. this is the portion from the existing nginx file http { log_format main '$remote_addr - $remote_user [$time_local] "$request" '

Re: [ansible-project] blockinfile help

2023-11-01 Thread Todd Lewis
Add "-vv" and "--diff" to your command line. Can you show us the relevant portion of the file /nginx/nginx.conf so we can try to reproduce? (And you really have that in the root? I'd expect /etc or /opt or /opt/local before /nginx, but, whatever.) On 11/1/23 2:27 PM, Narmada Karthika wrote:

Re: [ansible-project] blockinfile help

2023-11-01 Thread Narmada Karthika
- name: replace log_format settings on nginx ansible.builtin.replace: path: /nginx/nginx.conf regexp: '^log_format +main +[^;]+;\n' replace: 'log_format main {{ bits | map("quote") | join("\n ") }};\n' vars: bits: -

Re: [ansible-project] blockinfile help

2023-11-01 Thread Narmada Karthika
yes, I modified the playbook to my data accordingly .. On Wed, Nov 1, 2023 at 11:20 AM Todd Lewis wrote: > Then, um, fix what's wrong. (?) I'd be more specific, but you didn't give > me much to work with. Post the task and relevant variables. > Note the "path:" I used on my localhost isn't what

Re: [ansible-project] blockinfile help

2023-11-01 Thread Todd Lewis
Then, um, fix what's wrong. (?) I'd be more specific, but you didn't give me much to work with. Post the task and relevant variables. Note the "path:" I used on my localhost isn't what you need. Also, I didn't add the those extra data you want to add: *'$request_time ' '$upstream_response_time '

Re: [ansible-project] blockinfile help

2023-11-01 Thread Narmada Karthika
Thankyou, I tried the above playbook, there is no syntax error but it is not changing anything. On Tuesday, October 31, 2023 at 8:35:32 PM UTC-7 Todd Lewis wrote: > Something like this, perhaps: > > - name: Do the a.b.replace thing > ansible.builtin.replace: > path:

[ansible-project] Re: get item from nested loop item

2023-11-01 Thread Todd Lewis
It's hard to tell from this platform's poor support of indentation, but it appears "hostenv" is a list. Try loop: "{{ hostenv[0].Serverconf.Interface }}" On Wednesday, November 1, 2023 at 9:35:35 AM UTC-4 Vaishnave M wrote: > Hi, > > I have list of items in configuration files as variable >

Re: [ansible-project] Re: how to append to a line keeping

2023-11-01 Thread Todd Lewis
The short answer is no. If you want to modify the string with backrefs, then lineinfile will not create the line if it doesn't exist. But step back and consider your options for managing your override.conf file. A. The best scenario is to take total ownership of the entire file, generating

[ansible-project] Window Server Hardening CIS Benchmark

2023-11-01 Thread Shwe Linhtet
Hi community, I am seeking your advise on CIS hardening guide of window server 2012R2, 2016 or 2019 using ansible. I am relatively new in ansible knowledge and appreciate if you could share the code repo , sample codes , ansible galaxy , blogs or any other resources that I can start working

[ansible-project] get item from nested loop item

2023-11-01 Thread Vaishnave M
Hi, I have list of items in configuration files as variable hostenv: - env: test Serverconf: Resource: - mem: Interface: - { name: eth0, address: 10.0.10.2} - {eth1: .} Now, I would like to fetch and print the values from interface {{

[ansible-project] Re: how to append to a line keeping

2023-11-01 Thread Sameer Modak
Hello Team, I could figure out after 10 tries this is how i got it - name: append the line lineinfile: path: /tmp/hello.txt backrefs: yes regexp: '^(.*KAFKA_JMX_OPTS.*)$"'. < line: '\1

[ansible-project] how to append to a line keeping

2023-11-01 Thread Sameer Modak
We want to only append string -javaagent:{{jmxexporter_jar_path}}={{zookeeper_jmxexporter_port}}:{{zookeeper_jmxexporter_config_path}}"' to a file override.conf if we have "Environment="KAFKA_JMX_OPTS" in it else add new line "actual line"

Re: [ansible-project] restart service, check if port is ready to accept and then move to next host

2023-11-01 Thread Sameer Modak
Let me try with block and serial and get back to you On Wednesday, November 1, 2023 at 5:33:14 AM UTC+5:30 Will McDonald wrote: > Edit: s/along with a failed_when/along with wait_for/ > > On Tue, 31 Oct 2023 at 23:58, Will McDonald wrote: > >> I don't entirely understand your approach,