Re: [ansible-project] ansible playbook to add multiple lines to conf file

2023-01-31 Thread Tony Wong
if it was only 1 line then its fine

line_to_add: "server ntp1.domain.com iburst"

but not multiple lines

On Tue, Jan 31, 2023 at 1:17 PM Tony Wong  wrote:

> its this
>
> line:
> line_to_replace: "server ntp1a.domain.com iburst"
> replace_with: "#server ntp1a.domain.com iburst"
> line_to_add:
> - "server ntp1.domain.com
> 
>  iburst"
> - "server ntp2.domain.com
> 
>  iburst"
> - "server ntp3.domain.com
> 
>  iburst"
>
>
>
> On Tue, Jan 31, 2023 at 1:13 PM 'Rowe, Walter P. (Fed)' via Ansible
> Project  wrote:
>
>> This is a LIST all by itself. Its reference is line.line_to_add.
>>
>>   line_to_add:
>> - "server ntp1.domain.com
>> 
>>  iburst"
>> - "server ntp2.domain.com
>> 
>> iburst"
>> - "server ntp3.domain.com
>> 
>>  iburst"
>>
>>
>> You have no value set for "replace_with". What sets that?
>>
>> Walter
>> --
>> Walter Rowe, Division Chief
>> Infrastructure Services, OISM
>> Mobile: 202.355.4123
>>
>> On Jan 31, 2023, at 3:55 PM, Tony Wong  wrote:
>>
>> the source is in my vars.yml file
>>
>> line:
>>   line_to_add:
>> - "server ntp1.domain.com
>> 
>> iburst"
>> - "server ntp2.domain.com
>> 
>> iburst"
>> - "server ntp3.domain.com
>> 
>> iburst"
>>
>>
>> variable is line_to_add
>>
>>
>> On Tue, Jan 31, 2023 at 12:49 PM 'Rowe, Walter P. (Fed)' via Ansible
>> Project  wrote:
>>
>>> Where are you sourcing the "lines" you want to add to the file? What
>>> variable contains that list? You reference "line". What is the format/type
>>> of that variable?
>>>
>>> - name: add line
>>>   lineinfile:
>>> backup: no
>>> backrefs: no
>>> state: present
>>> path: 

Re: [ansible-project] ansible playbook to add multiple lines to conf file

2023-01-31 Thread Tony Wong
its this

line:
line_to_replace: "server ntp1a.domain.com iburst"
replace_with: "#server ntp1a.domain.com iburst"
line_to_add:
- "server ntp1.domain.com

 iburst"
- "server ntp2.domain.com

 iburst"
- "server ntp3.domain.com

 iburst"



On Tue, Jan 31, 2023 at 1:13 PM 'Rowe, Walter P. (Fed)' via Ansible Project
 wrote:

> This is a LIST all by itself. Its reference is line.line_to_add.
>
>   line_to_add:
> - "server ntp1.domain.com
> 
>  iburst"
> - "server ntp2.domain.com
> 
> iburst"
> - "server ntp3.domain.com
> 
>  iburst"
>
>
> You have no value set for "replace_with". What sets that?
>
> Walter
> --
> Walter Rowe, Division Chief
> Infrastructure Services, OISM
> Mobile: 202.355.4123
>
> On Jan 31, 2023, at 3:55 PM, Tony Wong  wrote:
>
> the source is in my vars.yml file
>
> line:
>   line_to_add:
> - "server ntp1.domain.com
> 
> iburst"
> - "server ntp2.domain.com
> 
> iburst"
> - "server ntp3.domain.com
> 
> iburst"
>
>
> variable is line_to_add
>
>
> On Tue, Jan 31, 2023 at 12:49 PM 'Rowe, Walter P. (Fed)' via Ansible
> Project  wrote:
>
>> Where are you sourcing the "lines" you want to add to the file? What
>> variable contains that list? You reference "line". What is the format/type
>> of that variable?
>>
>> - name: add line
>>   lineinfile:
>> backup: no
>> backrefs: no
>> state: present
>> path: "{{ file_path }}"
>> insertafter: "{{ item.search }}"
>> line: "{{ item.add }}"
>>   with_items:
>> - { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}"
>> }
>>
>>
>> Walter
>> --
>> Walter Rowe, Division Chief
>> 

Re: [ansible-project] ansible playbook to add multiple lines to conf file

2023-01-31 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
This is a LIST all by itself. Its reference is line.line_to_add.

  line_to_add:
- "server 
ntp1.domain.com
 iburst"
- "server 
ntp2.domain.com
  iburst"
- "server 
ntp3.domain.com
 iburst"

You have no value set for "replace_with". What sets that?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jan 31, 2023, at 3:55 PM, Tony Wong  wrote:

the source is in my vars.yml file

line:
  line_to_add:
- "server 
ntp1.domain.com
 iburst"
- "server 
ntp2.domain.com
  iburst"
- "server 
ntp3.domain.com
 iburst"


variable is line_to_add


On Tue, Jan 31, 2023 at 12:49 PM 'Rowe, Walter P. (Fed)' via Ansible Project 
mailto:ansible-project@googlegroups.com>> 
wrote:
Where are you sourcing the "lines" you want to add to the file? What variable 
contains that list? You reference "line". What is the format/type of that 
variable?

- name: add line
  lineinfile:
backup: no
backrefs: no
state: present
path: "{{ file_path }}"
insertafter: "{{ item.search }}"
line: "{{ item.add }}"
  with_items:
- { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jan 31, 2023, at 3:41 PM, Tony Wong 
mailto:tdubb...@gmail.com>> wrote:

trying to add multiple ntp servers to chrony.conf

- name: add line
lineinfile:
backup: no
backrefs: no
state: present
path: "{{ file_path }}"
insertafter: "{{ line.replace_with }}"
line: "{{ line.line_to_add }}"
with_items:
- { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }


but it only adds it as single line

any idea?


vars

line:

line_to_add:
- "server 
ntp1.domain.com
 iburst"
- "server 
ntp2.domain.com
 iburst"
- "server 

Re: [ansible-project] ansible playbook to add multiple lines to conf file

2023-01-31 Thread Tony Wong
here is my output

[WARNING]: The value "['server ntp1.domain.com  iburst', 'server
ntp2.domain.com iburst', 'server ntp3.domain.com iburst']" (type list) was
converted to "u"['server ntp1.domain.com iburst', 'server ntp2.domain.com
iburst', 'server ntp3.domain.com iburst']"" (type string). If this
does not look like what you expect, quote the entire value to ensure it
does no

On Tue, Jan 31, 2023 at 12:56 PM Richard Megginson 
wrote:

> There's also https://github.com/linux-system-roles/timesync
>
> On Tue, Jan 31, 2023 at 1:49 PM 'Rowe, Walter P. (Fed)' via Ansible
> Project  wrote:
>
>> Where are you sourcing the "lines" you want to add to the file? What
>> variable contains that list? You reference "line". What is the format/type
>> of that variable?
>>
>> - name: add line
>>   lineinfile:
>> backup: no
>> backrefs: no
>> state: present
>> path: "{{ file_path }}"
>> insertafter: "{{ item.search }}"
>> line: "{{ item.add }}"
>>   with_items:
>> - { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}"
>> }
>>
>>
>> Walter
>> --
>> Walter Rowe, Division Chief
>> Infrastructure Services, OISM
>> Mobile: 202.355.4123
>>
>> On Jan 31, 2023, at 3:41 PM, Tony Wong  wrote:
>>
>> trying to add multiple ntp servers to chrony.conf
>>
>> - name: add line
>> lineinfile:
>> backup: no
>> backrefs: no
>> state: present
>> path: "{{ file_path }}"
>> insertafter: "{{ line.replace_with }}"
>> line: "{{ line.line_to_add }}"
>> with_items:
>> - { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }
>>
>>
>> but it only adds it as single line
>>
>> any idea?
>>
>>
>> vars
>>
>> line:
>>
>> line_to_add:
>> - "server ntp1.domain.com iburst"
>> - "server ntp2.domain.com iburst"
>> - "server ntp3.domain.com iburst"
>>
>>
>> --
>> 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/836036dd-6862-4475-b509-786762a2a7cbn%40googlegroups.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/C1985159-C94B-4703-9CB7-9F032DD182FE%40nist.gov
>> 
>> .
>>
> --
> 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/Hm2pRcVckcE/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/CALF5A-%2BFZhAfS9Hvo%3DAtqf3T%2BfPA6mpTy8QpaZH%3Dsmd3-_5kTA%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/CALmkhkrqR6gMXqC2tCZK1Qw5s-NvR0R2r7UcHi5vvHFcoyh8Mw%40mail.gmail.com.


Re: [ansible-project] ansible playbook to add multiple lines to conf file

2023-01-31 Thread Richard Megginson
There's also https://github.com/linux-system-roles/timesync

On Tue, Jan 31, 2023 at 1:49 PM 'Rowe, Walter P. (Fed)' via Ansible Project
 wrote:

> Where are you sourcing the "lines" you want to add to the file? What
> variable contains that list? You reference "line". What is the format/type
> of that variable?
>
> - name: add line
>   lineinfile:
> backup: no
> backrefs: no
> state: present
> path: "{{ file_path }}"
> insertafter: "{{ item.search }}"
> line: "{{ item.add }}"
>   with_items:
> - { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }
>
>
> Walter
> --
> Walter Rowe, Division Chief
> Infrastructure Services, OISM
> Mobile: 202.355.4123
>
> On Jan 31, 2023, at 3:41 PM, Tony Wong  wrote:
>
> trying to add multiple ntp servers to chrony.conf
>
> - name: add line
> lineinfile:
> backup: no
> backrefs: no
> state: present
> path: "{{ file_path }}"
> insertafter: "{{ line.replace_with }}"
> line: "{{ line.line_to_add }}"
> with_items:
> - { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }
>
>
> but it only adds it as single line
>
> any idea?
>
>
> vars
>
> line:
>
> line_to_add:
> - "server ntp1.domain.com iburst"
> - "server ntp2.domain.com iburst"
> - "server ntp3.domain.com iburst"
>
>
> --
> 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/836036dd-6862-4475-b509-786762a2a7cbn%40googlegroups.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/C1985159-C94B-4703-9CB7-9F032DD182FE%40nist.gov
> 
> .
>

-- 
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/CALF5A-%2BFZhAfS9Hvo%3DAtqf3T%2BfPA6mpTy8QpaZH%3Dsmd3-_5kTA%40mail.gmail.com.


Re: [ansible-project] ansible playbook to add multiple lines to conf file

2023-01-31 Thread Tony Wong
the source is in my vars.yml file

line:
  line_to_add:
- "server ntp1.domain.com iburst"
- "server ntp2.domain.com  iburst"
- "server ntp3.domain.com iburst"


variable is line_to_add


On Tue, Jan 31, 2023 at 12:49 PM 'Rowe, Walter P. (Fed)' via Ansible
Project  wrote:

> Where are you sourcing the "lines" you want to add to the file? What
> variable contains that list? You reference "line". What is the format/type
> of that variable?
>
> - name: add line
>   lineinfile:
> backup: no
> backrefs: no
> state: present
> path: "{{ file_path }}"
> insertafter: "{{ item.search }}"
> line: "{{ item.add }}"
>   with_items:
> - { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }
>
>
> Walter
> --
> Walter Rowe, Division Chief
> Infrastructure Services, OISM
> Mobile: 202.355.4123
>
> On Jan 31, 2023, at 3:41 PM, Tony Wong  wrote:
>
> trying to add multiple ntp servers to chrony.conf
>
> - name: add line
> lineinfile:
> backup: no
> backrefs: no
> state: present
> path: "{{ file_path }}"
> insertafter: "{{ line.replace_with }}"
> line: "{{ line.line_to_add }}"
> with_items:
> - { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }
>
>
> but it only adds it as single line
>
> any idea?
>
>
> vars
>
> line:
>
> line_to_add:
> - "server ntp1.domain.com iburst"
> - "server ntp2.domain.com iburst"
> - "server ntp3.domain.com iburst"
>
>
> --
> 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/836036dd-6862-4475-b509-786762a2a7cbn%40googlegroups.com
> 
> .
>
>
> --
> 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/Hm2pRcVckcE/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/C1985159-C94B-4703-9CB7-9F032DD182FE%40nist.gov
> 
> .
>

-- 
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/CALmkhkqnn9nqL2vPsv2XKMtXA6s9XfiBjCqbQVPqD%2B-0M49e8w%40mail.gmail.com.


Re: [ansible-project] ansible playbook to add multiple lines to conf file

2023-01-31 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Where are you sourcing the "lines" you want to add to the file? What variable 
contains that list? You reference "line". What is the format/type of that 
variable?

- name: add line
  lineinfile:
backup: no
backrefs: no
state: present
path: "{{ file_path }}"
insertafter: "{{ item.search }}"
line: "{{ item.add }}"
  with_items:
- { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jan 31, 2023, at 3:41 PM, Tony Wong  wrote:

trying to add multiple ntp servers to chrony.conf

- name: add line
lineinfile:
backup: no
backrefs: no
state: present
path: "{{ file_path }}"
insertafter: "{{ line.replace_with }}"
line: "{{ line.line_to_add }}"
with_items:
- { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }


but it only adds it as single line

any idea?


vars

line:

line_to_add:
- "server ntp1.domain.com iburst"
- "server ntp2.domain.com iburst"
- "server ntp3.domain.com iburst"


--
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/836036dd-6862-4475-b509-786762a2a7cbn%40googlegroups.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/C1985159-C94B-4703-9CB7-9F032DD182FE%40nist.gov.