> On 07/29/2022 12:24 PM CEST Dick Visser <[email protected]> wrote:
> 
>  
> On Fri, 29 Jul 2022 at 12:02, dulhaver via Ansible Project
> <[email protected]> wrote:
> 
> > it seems neither
> >
> > ´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
> > - name: move legacy postgres - stat postgres_data
> >   stat: path="{{ postgres_data }}"
> >   register: postgres_data
> >
> > - name: move legacy postgres - rename $PGDATA to 
> > /opt/db/data/postgres/data_legacy
> >   command: mv "{{ postgres_data }}" "{{ postgres_data_legacy }}"  #
> >   when: postgres_data.stat.path
> >   become: true
> > ´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
> > nor
> >
> > ´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
> > - name: move legacy postgres - stat postgres_data
> >   stat: path="{{ postgres_data }}"
> >   register: postgres_data
> >
> > - name: move legacy postgres - rename $PGDATA to 
> > /opt/db/data/postgres/data_legacy
> >   command: mv "{{ postgres_data }}" "{{ postgres_data_legacy }}"  #
> >   when: postgres_data.path
> >   become: true
> > ´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
> >
> > seems to make any difference. When I put harcoded locations the dir is 
> > renamed, when I use the variables from the defaults/main.yml it isn't
> 
> Correct.
> I assumed it was obvious that my suggestion was for the variable in
> the command - because that is what the error is about.
> You used it in the 'when' clause - which does not make sense as that
> was OK to start with.
> But now I see another issue with your code. You use 'postgres_data' as
> a variable in the stat task, which you then overwrite with the results
> of that task.
> That is very confusing and the source of your error.
> Rather than describing things and then running the risk of
> misinterpretation again, perhaps it's better to just spell it out
> entirely:
> 
> 
> - name: move legacy postgres - stat postgres_data
>   stat: path="{{ postgres_data }}"
>   register: pgdatastat
> 
> - name: move legacy postgres - rename $PGDATA to
> /opt/db/data/postgres/data_legacy
>   command: mv "{{ pgdatastat.stat.path }}" "{{ postgres_data_legacy }}"
>   when: pgdatastat.stat.exists
> 

that works now, thx. 

Apparently I still will have to study what 'stat' acutally does under the hood 
before I really get what actually happens here and why.

-- 
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/1864000443.146.1659107140531%40office.mailbox.org.

Reply via email to