Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-25 Thread Sadanand Alegaonkar
hello Stefen,

I really appreciate your effort to understand my concern.

I am specifying mount_points variable in Inventory file and try to keep
copy

DC-N5K-01 ansible_host=** ansible_ssh= mount_points=["/var/log"]


 *-  name: list file
  shell: cd "{{item}}"; find *.log
  with_items: "{{mount_points}}"
  register: file
   * debug:
  var: file.results["stdout"]
   - name: rename file
 shell:  cp  file.results["stdout"]   file.results["stdout"]   .bkp




On Mon, 25 May 2020 at 16:03, Stefan Hornburg (Racke) 
wrote:

> On 5/25/20 11:36 AM, Sadanand Alegaonkar wrote:
> > Hello Stefan,
> >
> >   Yes log rotation is good option i will this further..
> >
> > I am working on file deletion use case. In that i am having different
> mount points directory, before deletion i need to
> > take backup of old file and delete
> > them .
> >
>
> There are still tons of archive and backup programs that could do that for
> you. But if you insist to do it your way,
> please use at least proper Ansible modules:
>
> - name: Find log files in /var/log
>   find:
> file_type: 'file'
> paths: '/var/log/'
> patterns: '*.log'
>   register: find_logs
> - name: Create backup files
>   copy:
> src: "{{ item.path }}"
> dest: "{{ item.path }}.bkp"
> owner: "{{ item.pw_name }}"
> group: "{{ item.gr_name }}"
> mode: "{{ item.mode }}"
> remote_src: true
>   with_items: "{{ find_logs.files }}"
> - name: Remove original file
>   file:
> state: absent
> path: "{{ item.path }}"
>with_items: "{{ find_logs.files }}"
>
> Regards
>  Racke
>
> > I added mount name in the inventory.
> >
> > Below is the Playbook...
> > And also i am trying to get output only for registered variables,  gives
> error like variable not defined
> > name: Rename listener Trace file and Delete
> > hosts: dbhost
> > gather_facts: no
> > tasks:
> >
> >   * name: list file
> > shell: cd "{{item}}"; find *.log
> > with_items: "{{mount_points}}"
> > register: file
> >   * debug:
> > var: file.results["stdout"]
> >
> >
> > Output:
> > "file.results["stdout"]": "VARIABLE IS NOT DEFINED!: 'list object' has
> no attribute 'stdout'"
> >
> >
> > On Mon, 25 May 2020 at 14:51, Stefan Hornburg (Racke)  > wrote:
> >
> > On 5/25/20 10:42 AM, Sadanand Alegaonkar wrote:
> > > hello Stefan,
> > >
> > > I have to add more task in the playbook, that's why i going with
> this methods.
> >
> > That is hardly a good reason, especially without further explanation.
> >
> > Regards
> >  Racke
> >
> > >
> > > On Mon, 25 May 2020 at 10:46, Stefan Hornburg (Racke) <
> ra...@linuxia.de 
> > >> wrote:
> > >
> > > On 5/25/20 4:52 AM, Sadanand Alegaonkar wrote:
> > > > Hello Dick,
> > > >
> > > > Thanks for giving reply,
> > > > Yes corrected this error but the purpose is not getting
> fulfilled.
> > > >
> > > > I was trying to rename old file in the file system. it is
> giving below error.
> > > >
> > > > getting "file.results["stdout"]": "VARIABLE IS NOT DEFINED!"
> error
> > >
> > > Hello Sadanand,
> > >
> > > it would be much better to use existing applications on the
> server itself, e.g. logrotate or one
> > > of the dozens of backup programs for Linux.
> > >
> > > Instead of using the shell, I would recommend "find" and
> "copy" modules.
> > >
> > > Regards
> > > Racke
> > >
> > > >
> > > > On Sun, 24 May 2020 at 22:22, Dick Visser <
> dick.vis...@geant.org 
> > >
> > > 
>  >  > > >
> > > >
> > > >
> > > > On Sun, 24 May 2020 at 08:46, Sadanand Alegaonkar <
> sadanandalegaon...@gmail.com
> > 
> > > >
> > > > 
> >  > > >
> > > > SUMMARY
> > > >
> > > > I trynig to take backup of existing file. reported
> below error
> > > >
> > > > ERROR! failed at splitting arguments, either an
> unbalanced jinja2 block or quotes: cp "{{file.stdout}"
> > > > "{{file.stdout}}"_bkp
> > > >
> > > >
> > > >
> > > > This error is correct, see below
> > > >
> > > >
> > > > ansible-playbook 

Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-25 Thread Stefan Hornburg (Racke)
On 5/25/20 11:36 AM, Sadanand Alegaonkar wrote:
> Hello Stefan,
> 
>   Yes log rotation is good option i will this further.. 
>  
> I am working on file deletion use case. In that i am having different mount 
> points directory, before deletion i need to
> take backup of old file and delete
> them .
>  

There are still tons of archive and backup programs that could do that for you. 
But if you insist to do it your way,
please use at least proper Ansible modules:

- name: Find log files in /var/log
  find:
file_type: 'file'
paths: '/var/log/'
patterns: '*.log'
  register: find_logs
- name: Create backup files
  copy:
src: "{{ item.path }}"
dest: "{{ item.path }}.bkp"
owner: "{{ item.pw_name }}"
group: "{{ item.gr_name }}"
mode: "{{ item.mode }}"
remote_src: true
  with_items: "{{ find_logs.files }}"
- name: Remove original file
  file:
state: absent
path: "{{ item.path }}"
   with_items: "{{ find_logs.files }}"

Regards
 Racke

> I added mount name in the inventory.
> 
> Below is the Playbook...
> And also i am trying to get output only for registered variables,  gives 
> error like variable not defined
> name: Rename listener Trace file and Delete
> hosts: dbhost
> gather_facts: no
> tasks:
> 
>   * name: list file
> shell: cd "{{item}}"; find *.log
> with_items: "{{mount_points}}"
> register: file
>   * debug:
> var: file.results["stdout"]
> 
> 
> Output:
> "file.results["stdout"]": "VARIABLE IS NOT DEFINED!: 'list object' has no 
> attribute 'stdout'"  
> 
> 
> On Mon, 25 May 2020 at 14:51, Stefan Hornburg (Racke)  > wrote:
> 
> On 5/25/20 10:42 AM, Sadanand Alegaonkar wrote:
> > hello Stefan,
> >
> > I have to add more task in the playbook, that's why i going with this 
> methods.
> 
> That is hardly a good reason, especially without further explanation.
> 
> Regards
>          Racke
> 
> >
> > On Mon, 25 May 2020 at 10:46, Stefan Hornburg (Racke)  
> >> wrote:
> >
> >     On 5/25/20 4:52 AM, Sadanand Alegaonkar wrote:
> >     > Hello Dick,
> >     >
> >     > Thanks for giving reply, 
> >     > Yes corrected this error but the purpose is not getting fulfilled.
> >     >
> >     > I was trying to rename old file in the file system. it is giving 
> below error.
> >     >
> >     > getting "file.results["stdout"]": "VARIABLE IS NOT DEFINED!" 
> error 
> >
> >     Hello Sadanand,
> >
> >     it would be much better to use existing applications on the server 
> itself, e.g. logrotate or one
> >     of the dozens of backup programs for Linux.
> >
> >     Instead of using the shell, I would recommend "find" and "copy" 
> modules.
> >
> >     Regards
> >             Racke
> >
> >     >
> >     > On Sun, 24 May 2020 at 22:22, Dick Visser  
> >
> >      
>   >     >
> >     >
> >     >
> >     >     On Sun, 24 May 2020 at 08:46, Sadanand Alegaonkar 
>  
> >      >
> >     >      
>   >     >
> >     >         SUMMARY
> >     >
> >     >         I trynig to take backup of existing file. reported below 
> error
> >     >
> >     >         ERROR! failed at splitting arguments, either an 
> unbalanced jinja2 block or quotes: cp "{{file.stdout}"
> >     >         "{{file.stdout}}"_bkp
> >     >
> >     >
> >     >
> >     >     This error is correct, see below 
> >     >
> >     >
> >     >         ansible-playbook pb_DBrename_deletefile.yml -i alertdbhost
> >     >
> >     >         ISSUE TYPE
> >     >
> >     >         [root@XX database]#
> >     >
> >     >         ERROR! failed at splitting arguments, either an 
> unbalanced jinja2 block or quotes: cp "{{file.stdout}"
> >     >         "{{file.stdout}}"_bkp
> >     >
> >     >
> >     >         Ansible Version:
> >     >
> >     >         [root@XX database]# ansible --version
> >     >         ansible 2.8.5
> >     >           config file = /etc/ansible/ansible.cfg
> >     >           configured module search path = 
> [u'/root/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
> >     >           ansible python module location = 
> /usr/lib/python2.7/site-packages/ansible
> >     > 

Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-25 Thread Sadanand Alegaonkar
Hello Stefan,

  Yes log rotation is good option i will this further..

I am working on file deletion use case. In that i am having different mount
points directory, before deletion i need to take backup of old file and
delete
them .

I added mount name in the inventory.

Below is the Playbook...
And also i am trying to get output only for registered variables,  gives
error like variable not defined
name: Rename listener Trace file and Delete
hosts: dbhost
gather_facts: no
tasks:

   - name: list file
   shell: cd "{{item}}"; find *.log
   with_items: "{{mount_points}}"
   register: file
   - debug:
   var: file.results["stdout"]


Output:
"file.results["stdout"]": "VARIABLE IS NOT DEFINED!: 'list object' has no
attribute 'stdout'"


On Mon, 25 May 2020 at 14:51, Stefan Hornburg (Racke) 
wrote:

> On 5/25/20 10:42 AM, Sadanand Alegaonkar wrote:
> > hello Stefan,
> >
> > I have to add more task in the playbook, that's why i going with this
> methods.
>
> That is hardly a good reason, especially without further explanation.
>
> Regards
>  Racke
>
> >
> > On Mon, 25 May 2020 at 10:46, Stefan Hornburg (Racke)  > wrote:
> >
> > On 5/25/20 4:52 AM, Sadanand Alegaonkar wrote:
> > > Hello Dick,
> > >
> > > Thanks for giving reply,
> > > Yes corrected this error but the purpose is not getting fulfilled.
> > >
> > > I was trying to rename old file in the file system. it is giving
> below error.
> > >
> > > getting "file.results["stdout"]": "VARIABLE IS NOT DEFINED!" error
> >
> > Hello Sadanand,
> >
> > it would be much better to use existing applications on the server
> itself, e.g. logrotate or one
> > of the dozens of backup programs for Linux.
> >
> > Instead of using the shell, I would recommend "find" and "copy"
> modules.
> >
> > Regards
> > Racke
> >
> > >
> > > On Sun, 24 May 2020 at 22:22, Dick Visser  
> > >>
> wrote:
> > >
> > >
> > >
> > > On Sun, 24 May 2020 at 08:46, Sadanand Alegaonkar <
> sadanandalegaon...@gmail.com
> > 
> > > >> wrote:
> > >
> > > SUMMARY
> > >
> > > I trynig to take backup of existing file. reported below
> error
> > >
> > > ERROR! failed at splitting arguments, either an unbalanced
> jinja2 block or quotes: cp "{{file.stdout}"
> > > "{{file.stdout}}"_bkp
> > >
> > >
> > >
> > > This error is correct, see below
> > >
> > >
> > > ansible-playbook pb_DBrename_deletefile.yml -i alertdbhost
> > >
> > > ISSUE TYPE
> > >
> > > [root@XX database]#
> > >
> > > ERROR! failed at splitting arguments, either an unbalanced
> jinja2 block or quotes: cp "{{file.stdout}"
> > > "{{file.stdout}}"_bkp
> > >
> > >
> > > Ansible Version:
> > >
> > > [root@XX database]# ansible --version
> > > ansible 2.8.5
> > >   config file = /etc/ansible/ansible.cfg
> > >   configured module search path =
> [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
> > >   ansible python module location =
> /usr/lib/python2.7/site-packages/ansible
> > >   executable location = /bin/ansible
> > >   python version = 2.7.5 (default, Jun 11 2019, 12:19:05)
> [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
> > >
> > >
> > > OS / ENVIRONMENT / INSTALL METHOD
> > >
> > > Red Hat Enterprise Linux Server release 7.6 (Maipo)
> > >
> > > STEPS TO REPRODUCE
> > > ---
> > >  - name: Rename listener Trace file and Delete
> > >hosts: dbhost
> > >gather_facts: no
> > >tasks:
> > >  - name: list file
> > >shell: cd "{{item}}"; find *.log
> > >with_items: "{{mount_points}}"
> > >register: file
> > >  - debug:
> > >  var: file
> > >  - name: Rename file
> > >shell: cp "{{file.stdout}" "
> > >
> > >
> > > You forgot a curly here
> > >
> > >
> > > {{file.stdout}}"_bkp
> > >   # with_items: "{{file.stdout}}"
> > >register: file1
> > >  - debug:
> > >  var: file1
> > >
> > >
> > > EXPECTED RESULTS
> > > File created with bkp extension
> > >
> > > ACTUAL RESULTS
> > > ERROR! failed at splitting arguments, either an unbalanced
> jinja2 block or quotes: cp "{{file.stdout}"
> > > 

Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-25 Thread Stefan Hornburg (Racke)
On 5/25/20 10:42 AM, Sadanand Alegaonkar wrote:
> hello Stefan,
> 
> I have to add more task in the playbook, that's why i going with this methods.

That is hardly a good reason, especially without further explanation.

Regards
 Racke

> 
> On Mon, 25 May 2020 at 10:46, Stefan Hornburg (Racke)  > wrote:
> 
> On 5/25/20 4:52 AM, Sadanand Alegaonkar wrote:
> > Hello Dick,
> >
> > Thanks for giving reply, 
> > Yes corrected this error but the purpose is not getting fulfilled.
> >
> > I was trying to rename old file in the file system. it is giving below 
> error.
> >
> > getting "file.results["stdout"]": "VARIABLE IS NOT DEFINED!" error 
> 
> Hello Sadanand,
> 
> it would be much better to use existing applications on the server 
> itself, e.g. logrotate or one
> of the dozens of backup programs for Linux.
> 
> Instead of using the shell, I would recommend "find" and "copy" modules.
> 
> Regards
>         Racke
> 
> >
> > On Sun, 24 May 2020 at 22:22, Dick Visser  
> >> wrote:
> >
> >
> >
> >     On Sun, 24 May 2020 at 08:46, Sadanand Alegaonkar 
>  
> >      >> wrote:
> >
> >         SUMMARY
> >
> >         I trynig to take backup of existing file. reported below error
> >
> >         ERROR! failed at splitting arguments, either an unbalanced 
> jinja2 block or quotes: cp "{{file.stdout}"
> >         "{{file.stdout}}"_bkp
> >
> >
> >
> >     This error is correct, see below 
> >
> >
> >         ansible-playbook pb_DBrename_deletefile.yml -i alertdbhost
> >
> >         ISSUE TYPE
> >
> >         [root@XX database]#
> >
> >         ERROR! failed at splitting arguments, either an unbalanced 
> jinja2 block or quotes: cp "{{file.stdout}"
> >         "{{file.stdout}}"_bkp
> >
> >
> >         Ansible Version:
> >
> >         [root@XX database]# ansible --version
> >         ansible 2.8.5
> >           config file = /etc/ansible/ansible.cfg
> >           configured module search path = 
> [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
> >           ansible python module location = 
> /usr/lib/python2.7/site-packages/ansible
> >           executable location = /bin/ansible
> >           python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 
> 4.8.5 20150623 (Red Hat 4.8.5-36)]
> >
> >
> >         OS / ENVIRONMENT / INSTALL METHOD
> >
> >         Red Hat Enterprise Linux Server release 7.6 (Maipo)
> >
> >         STEPS TO REPRODUCE
> >         ---
> >          - name: Rename listener Trace file and Delete
> >            hosts: dbhost
> >            gather_facts: no
> >            tasks:
> >              - name: list file
> >                shell: cd "{{item}}"; find *.log
> >                with_items: "{{mount_points}}"
> >                register: file
> >              - debug:
> >                  var: file
> >              - name: Rename file
> >                shell: cp "{{file.stdout}" "
> >
> >
> >     You forgot a curly here 
> >
> >
> >         {{file.stdout}}"_bkp
> >               # with_items: "{{file.stdout}}"
> >                register: file1
> >              - debug:
> >                  var: file1
> >
> >
> >         EXPECTED RESULTS
> >         File created with bkp extension
> >
> >         ACTUAL RESULTS
> >         ERROR! failed at splitting arguments, either an unbalanced 
> jinja2 block or quotes: cp "{{file.stdout}"
> >         "{{file.stdout}}"_bkp
> >
> >         The error appears to be in 
> '/etc/ansible/database/pb_DBrename_deletefile.yml': line 12, column 8, but may
> >         be elsewhere in the file depending on the exact syntax problem.
> >
> >         The offending line appears to be:
> >
> >                  var: file
> >              - name: Rename file
> >                ^ here
> >
> >         --
> >         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
> >         
> 

Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-25 Thread Dick Visser
On Mon, 25 May 2020 at 10:42, Sadanand Alegaonkar
 wrote:
>
> hello Stefan,
>
> I have to add more task in the playbook, that's why i going with this methods.

I don't see why you have to?
Duplicating logrotate functionality through ansible through shell
scripts that need then need to be run manually sounds like a lot of
extra, error prone work.

"What an engineer can do is rarely what he should do"



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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/CAL8fbwNXvuWcbNh41FaQhoK2VXvpKdsuTePsccr0gptaVv_rGA%40mail.gmail.com.


Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-25 Thread Sadanand Alegaonkar
hello Stefan,

I have to add more task in the playbook, that's why i going with this
methods.

On Mon, 25 May 2020 at 10:46, Stefan Hornburg (Racke) 
wrote:

> On 5/25/20 4:52 AM, Sadanand Alegaonkar wrote:
> > Hello Dick,
> >
> > Thanks for giving reply,
> > Yes corrected this error but the purpose is not getting fulfilled.
> >
> > I was trying to rename old file in the file system. it is giving below
> error.
> >
> > getting "file.results["stdout"]": "VARIABLE IS NOT DEFINED!" error
>
> Hello Sadanand,
>
> it would be much better to use existing applications on the server itself,
> e.g. logrotate or one
> of the dozens of backup programs for Linux.
>
> Instead of using the shell, I would recommend "find" and "copy" modules.
>
> Regards
> Racke
>
> >
> > On Sun, 24 May 2020 at 22:22, Dick Visser  > wrote:
> >
> >
> >
> > On Sun, 24 May 2020 at 08:46, Sadanand Alegaonkar <
> sadanandalegaon...@gmail.com
> > > wrote:
> >
> > SUMMARY
> >
> > I trynig to take backup of existing file. reported below error
> >
> > ERROR! failed at splitting arguments, either an unbalanced
> jinja2 block or quotes: cp "{{file.stdout}"
> > "{{file.stdout}}"_bkp
> >
> >
> >
> > This error is correct, see below
> >
> >
> > ansible-playbook pb_DBrename_deletefile.yml -i alertdbhost
> >
> > ISSUE TYPE
> >
> > [root@XX database]#
> >
> > ERROR! failed at splitting arguments, either an unbalanced
> jinja2 block or quotes: cp "{{file.stdout}"
> > "{{file.stdout}}"_bkp
> >
> >
> > Ansible Version:
> >
> > [root@XX database]# ansible --version
> > ansible 2.8.5
> >   config file = /etc/ansible/ansible.cfg
> >   configured module search path =
> [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
> >   ansible python module location =
> /usr/lib/python2.7/site-packages/ansible
> >   executable location = /bin/ansible
> >   python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC
> 4.8.5 20150623 (Red Hat 4.8.5-36)]
> >
> >
> > OS / ENVIRONMENT / INSTALL METHOD
> >
> > Red Hat Enterprise Linux Server release 7.6 (Maipo)
> >
> > STEPS TO REPRODUCE
> > ---
> >  - name: Rename listener Trace file and Delete
> >hosts: dbhost
> >gather_facts: no
> >tasks:
> >  - name: list file
> >shell: cd "{{item}}"; find *.log
> >with_items: "{{mount_points}}"
> >register: file
> >  - debug:
> >  var: file
> >  - name: Rename file
> >shell: cp "{{file.stdout}" "
> >
> >
> > You forgot a curly here
> >
> >
> > {{file.stdout}}"_bkp
> >   # with_items: "{{file.stdout}}"
> >register: file1
> >  - debug:
> >  var: file1
> >
> >
> > EXPECTED RESULTS
> > File created with bkp extension
> >
> > ACTUAL RESULTS
> > ERROR! failed at splitting arguments, either an unbalanced
> jinja2 block or quotes: cp "{{file.stdout}"
> > "{{file.stdout}}"_bkp
> >
> > The error appears to be in
> '/etc/ansible/database/pb_DBrename_deletefile.yml': line 12, column 8, but
> may
> > be elsewhere in the file depending on the exact syntax problem.
> >
> > The offending line appears to be:
> >
> >  var: file
> >  - name: Rename file
> >^ here
> >
> > --
> > 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  ansible-project+unsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/a27726ee-fe4f-4adc-a58a-8467e633341a%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/a27726ee-fe4f-4adc-a58a-8467e633341a%40googlegroups.com?utm_medium=email_source=footer
> >.
> >
> > --
> > Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
> >
> > --
> > 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  ansible-project+unsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwOaJOfb1Ai3uOXKQP2iUP_5gFCeoWk4iayJbiwL6fZRjw%40mail.gmail.com
> > <
> 

Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-24 Thread Stefan Hornburg (Racke)
On 5/25/20 4:52 AM, Sadanand Alegaonkar wrote:
> Hello Dick,
> 
> Thanks for giving reply, 
> Yes corrected this error but the purpose is not getting fulfilled.
> 
> I was trying to rename old file in the file system. it is giving below error.
> 
> getting "file.results["stdout"]": "VARIABLE IS NOT DEFINED!" error  

Hello Sadanand,

it would be much better to use existing applications on the server itself, e.g. 
logrotate or one
of the dozens of backup programs for Linux.

Instead of using the shell, I would recommend "find" and "copy" modules.

Regards
Racke

> 
> On Sun, 24 May 2020 at 22:22, Dick Visser  > wrote:
> 
> 
> 
> On Sun, 24 May 2020 at 08:46, Sadanand Alegaonkar 
>  > wrote:
> 
> SUMMARY
> 
> I trynig to take backup of existing file. reported below error
> 
> ERROR! failed at splitting arguments, either an unbalanced jinja2 
> block or quotes: cp "{{file.stdout}"
> "{{file.stdout}}"_bkp
> 
> 
> 
> This error is correct, see below 
> 
> 
> ansible-playbook pb_DBrename_deletefile.yml -i alertdbhost
> 
> ISSUE TYPE
> 
> [root@XX database]#
> 
> ERROR! failed at splitting arguments, either an unbalanced jinja2 
> block or quotes: cp "{{file.stdout}"
> "{{file.stdout}}"_bkp
> 
> 
> Ansible Version:
> 
> [root@XX database]# ansible --version
> ansible 2.8.5
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = [u'/root/.ansible/plugins/modules', 
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = 
> /usr/lib/python2.7/site-packages/ansible
>   executable location = /bin/ansible
>   python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 
> 20150623 (Red Hat 4.8.5-36)]
> 
> 
> OS / ENVIRONMENT / INSTALL METHOD
> 
> Red Hat Enterprise Linux Server release 7.6 (Maipo)
> 
> STEPS TO REPRODUCE
> ---
>  - name: Rename listener Trace file and Delete
>    hosts: dbhost
>    gather_facts: no
>    tasks:
>      - name: list file
>        shell: cd "{{item}}"; find *.log
>        with_items: "{{mount_points}}"
>        register: file
>      - debug:
>          var: file
>      - name: Rename file
>        shell: cp "{{file.stdout}" "
> 
> 
> You forgot a curly here 
> 
> 
> {{file.stdout}}"_bkp
>       # with_items: "{{file.stdout}}"
>        register: file1
>      - debug:
>          var: file1
> 
> 
> EXPECTED RESULTS
> File created with bkp extension
> 
> ACTUAL RESULTS
> ERROR! failed at splitting arguments, either an unbalanced jinja2 
> block or quotes: cp "{{file.stdout}"
> "{{file.stdout}}"_bkp
> 
> The error appears to be in 
> '/etc/ansible/database/pb_DBrename_deletefile.yml': line 12, column 8, but may
> be elsewhere in the file depending on the exact syntax problem.
> 
> The offending line appears to be:
> 
>          var: file
>      - name: Rename file
>        ^ here
> 
> -- 
> 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/a27726ee-fe4f-4adc-a58a-8467e633341a%40googlegroups.com
> 
> .
> 
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
> 
> -- 
> 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/CAL8fbwOaJOfb1Ai3uOXKQP2iUP_5gFCeoWk4iayJbiwL6fZRjw%40mail.gmail.com
> 
> .
> 
> 
> 
> -- 
> Thanks and Regards
>  Sadanand V.Alegaonkar
> Cell No:9975632660
> 
> -- 
> 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
> 

Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-24 Thread Sadanand Alegaonkar
Hello Dick,

Thanks for giving reply,
Yes corrected this error but the purpose is not getting fulfilled.

I was trying to rename old file in the file system. it is giving below
error.

getting "file.results["stdout"]": "VARIABLE IS NOT DEFINED!" error

On Sun, 24 May 2020 at 22:22, Dick Visser  wrote:

>
>
> On Sun, 24 May 2020 at 08:46, Sadanand Alegaonkar <
> sadanandalegaon...@gmail.com> wrote:
>
>> SUMMARY
>>
>> I trynig to take backup of existing file. reported below error
>>
>> ERROR! failed at splitting arguments, either an unbalanced jinja2 block
>> or quotes: cp "{{file.stdout}" "{{file.stdout}}"_bkp
>>
>
>
> This error is correct, see below
>
>>
>> ansible-playbook pb_DBrename_deletefile.yml -i alertdbhost
>>
>> ISSUE TYPE
>>
>> [root@XX database]#
>>
>> ERROR! failed at splitting arguments, either an unbalanced jinja2 block
>> or quotes: cp "{{file.stdout}" "{{file.stdout}}"_bkp
>>
>>
>> Ansible Version:
>>
>> [root@XX database]# ansible --version
>> ansible 2.8.5
>>   config file = /etc/ansible/ansible.cfg
>>   configured module search path = [u'/root/.ansible/plugins/modules',
>> u'/usr/share/ansible/plugins/modules']
>>   ansible python module location =
>> /usr/lib/python2.7/site-packages/ansible
>>   executable location = /bin/ansible
>>   python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5
>> 20150623 (Red Hat 4.8.5-36)]
>>
>>
>> OS / ENVIRONMENT / INSTALL METHOD
>>
>> Red Hat Enterprise Linux Server release 7.6 (Maipo)
>>
>> STEPS TO REPRODUCE
>> ---
>>  - name: Rename listener Trace file and Delete
>>hosts: dbhost
>>gather_facts: no
>>tasks:
>>  - name: list file
>>shell: cd "{{item}}"; find *.log
>>with_items: "{{mount_points}}"
>>register: file
>>  - debug:
>>  var: file
>>  - name: Rename file
>>shell: cp "{{file.stdout}" "
>>
>
> You forgot a curly here
>
>
> {{file.stdout}}"_bkp
>>   # with_items: "{{file.stdout}}"
>>register: file1
>>  - debug:
>>  var: file1
>>
>>
>> EXPECTED RESULTS
>> File created with bkp extension
>>
>> ACTUAL RESULTS
>> ERROR! failed at splitting arguments, either an unbalanced jinja2 block
>> or quotes: cp "{{file.stdout}" "{{file.stdout}}"_bkp
>>
>> The error appears to be in
>> '/etc/ansible/database/pb_DBrename_deletefile.yml': line 12, column 8, but
>> may
>> be elsewhere in the file depending on the exact syntax problem.
>>
>> The offending line appears to be:
>>
>>  var: file
>>  - name: Rename file
>>^ here
>>
>> --
>> 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/a27726ee-fe4f-4adc-a58a-8467e633341a%40googlegroups.com
>> 
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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/CAL8fbwOaJOfb1Ai3uOXKQP2iUP_5gFCeoWk4iayJbiwL6fZRjw%40mail.gmail.com
> 
> .
>


-- 
Thanks and Regards
 Sadanand V.Alegaonkar
Cell No:9975632660

-- 
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/CA%2Bo9MBTXKZM14f253-nnRa96um6hvuVdTBEyBF8Ye9KZ-wgwug%40mail.gmail.com.


Re: [ansible-project] unable to generate backup file with registered variable in ansible

2020-05-24 Thread Dick Visser
On Sun, 24 May 2020 at 08:46, Sadanand Alegaonkar <
sadanandalegaon...@gmail.com> wrote:

> SUMMARY
>
> I trynig to take backup of existing file. reported below error
>
> ERROR! failed at splitting arguments, either an unbalanced jinja2 block or
> quotes: cp "{{file.stdout}" "{{file.stdout}}"_bkp
>


This error is correct, see below

>
> ansible-playbook pb_DBrename_deletefile.yml -i alertdbhost
>
> ISSUE TYPE
>
> [root@XX database]#
>
> ERROR! failed at splitting arguments, either an unbalanced jinja2 block or
> quotes: cp "{{file.stdout}" "{{file.stdout}}"_bkp
>
>
> Ansible Version:
>
> [root@XX database]# ansible --version
> ansible 2.8.5
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = [u'/root/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/site-packages/ansible
>   executable location = /bin/ansible
>   python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5
> 20150623 (Red Hat 4.8.5-36)]
>
>
> OS / ENVIRONMENT / INSTALL METHOD
>
> Red Hat Enterprise Linux Server release 7.6 (Maipo)
>
> STEPS TO REPRODUCE
> ---
>  - name: Rename listener Trace file and Delete
>hosts: dbhost
>gather_facts: no
>tasks:
>  - name: list file
>shell: cd "{{item}}"; find *.log
>with_items: "{{mount_points}}"
>register: file
>  - debug:
>  var: file
>  - name: Rename file
>shell: cp "{{file.stdout}" "
>

You forgot a curly here


{{file.stdout}}"_bkp
>   # with_items: "{{file.stdout}}"
>register: file1
>  - debug:
>  var: file1
>
>
> EXPECTED RESULTS
> File created with bkp extension
>
> ACTUAL RESULTS
> ERROR! failed at splitting arguments, either an unbalanced jinja2 block or
> quotes: cp "{{file.stdout}" "{{file.stdout}}"_bkp
>
> The error appears to be in
> '/etc/ansible/database/pb_DBrename_deletefile.yml': line 12, column 8, but
> may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>  var: file
>  - name: Rename file
>^ here
>
> --
> 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/a27726ee-fe4f-4adc-a58a-8467e633341a%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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/CAL8fbwOaJOfb1Ai3uOXKQP2iUP_5gFCeoWk4iayJbiwL6fZRjw%40mail.gmail.com.