Syntax error in Variable

Hi All,

Having trouble with this bit of code; it’s intended for AIX, but the error happens before the module get’s sent to the AIX server. I’m thinking I made a syntax error somewhere but I cannot find it :frowning:


###############

AIX hosts krijgen deze behandeling

  • name: Oracle | Creer structuur
    action: file
    path=/opt/oracle/admin/network/{{ item }}/
    state=directory
    recurse=yes
    owner=oracle
    group=dbamgr
    with_items:

  • admin

  • log

  • trace
    tags:

  • orabestanden

  • name: Oracle | Kopieer bestanden
    action: copy
    backup=yes
    src=/media/storage/DM/Transfer/Oracle/SQLNet/aix/{{ item }}
    force=yes
    dest=/opt/oracle/admin/network/admin/{{ item }}
    owner=oracle
    group=dbamgr
    with_items: orafiles
    register: nieuweversiegeplaatst
    tags:

  • orabestanden

  • name: Oracle | Ophalen welke versie’s van Oracle er zijn
    action: shell ls /opt/oracle/product/
    register: oracle_versions
    tags:

  • orabestanden

  • name: Oracle | Admin pad uitvogelen
    action: shell find /opt/oracle/product/{{ item }} -type d -name admin | grep -i network | egrep -v “11g|filemap”
    with_items:

  • ${oracle_versions.stdout_lines}
    register: oracle_admin_path
    tags:

  • orabestanden

  • name: Oracle | Verwijder links/bestanden
    action: file
    state=absent
    dest={{ item[0] }}/{{ item[1] }}
    with_nested:

  • ${oracle_admin_path.stdout_lines}

  • $orafiles
    when: nieuweversiegeplaatst.changed
    tags:

  • orabestanden

  • name: Oracle | Creeer link’s
    action: file
    state=link
    src=/opt/oracle/admin/network/admin/{{ item[1] }}
    dest={{ item[0] }}/{{ item[1] }}
    owner=oracle
    group=dba
    with_nested:
  • ${oracle_admin_path.stdout_lines}
  • $orafiles
    when: nieuweversiegeplaatst.changed
    tags:
  • orabestanden

But when I run it, I get this:

TASK: [Oracle | Verwijder links/bestanden] ************************************
fatal: [taixkaren] => cannot resolve: ${oracle_admin_path.stdout_lines}
FATAL: all hosts have already failed – aborting

The strange thing is, I have the same code which is intended for Linux:


###############

Linux hosts krijgen deze behandeling

  • name: Oracle | Creer structuur
    action: file
    path=/usr/lib/oracle/xe/app/oracle/network/{{item}}/
    state=directory
    recurse=yes
    owner=oracle
    group=dba
    with_items:
  • admin
  • log
  • trace
    tags:
  • orabestanden
  • name: Oracle | Kopieer bestanden
    action: copy
    backup=yes
    src=/media/storage/DM/Transfer/Oracle/SQLNet/linux/{{item}}
    force=yes
    dest=/usr/lib/oracle/xe/app/oracle/network/admin/{{item}}
    owner=oracle
    group=dba
    with_items: orafiles
    register: nieuweversiegeplaatst
    tags:
  • orabestanden
  • name: Oracle | Admin pad uitvogelen
    action: shell find /usr/lib/oracle/xe/app/oracle/product/ -type d -name admin | grep -i network
    register: oracle_admin_path
    tags:

  • orabestanden

  • name: Oracle | Verwijder links/bestanden
    action: file
    state=absent
    dest={{ item[0] }}/{{ item[1] }}
    with_nested:

  • ${oracle_admin_path.stdout_lines}

  • $orafiles
    when: nieuweversiegeplaatst.changed
    tags:

  • orabestanden

  • name: Oracle | Creeer link’s
    action: file
    state=link
    src=/usr/lib/oracle/xe/app/oracle/network/admin/${item[1]}
    dest={{item[0] }}/{{ item[1] }}
    owner=oracle
    group=dba
    with_nested:

  • ${oracle_admin_path.stdout_lines}

  • $orafiles
    when: nieuweversiegeplaatst.changed
    tags:

  • orabestanden

Which is working flawlessly!

If the reader would take a look for me, much apreciated!

Mark

I see you are still using old style variables, which you should not be.

This may not be related to your error, you can just do:

with_items: oracle_admin_path.stdout_lines

Are you sure? Because with that change, it fails replacing it as a variable completely:

This:

  • name: Oracle | Admin pad uitvogelen
    action: shell find /opt/oracle/product/{{ item }} -type d -name admin | grep -i network | egrep -v “11g|filemap”
    with_items:
  • oracle_versions.stdout_lines
    register: oracle_admin_path
    tags:
  • orabestanden

Now results in:

TASK: [Oracle | Admin pad uitvogelen] *****************************************
ESTABLISH CONNECTION FOR USER: mmaas on PORT 22 TO taixkaren
EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1378470995.11-131618494508055 && chmod a+rx $HOME/.ansible/tmp/ansible-1378470995.11-131618494508055 && echo $HOME/.ansible/tmp/ansible-1378470995.11-131618494508055’
REMOTE_MODULE command find /opt/oracle/product/oracle_versions.stdout_lines -type d -name admin | grep -i network | egrep -v “11g|filemap” #USE_SHELL
PUT /tmp/tmpmUk5H7 TO /home/mmaas/.ansible/tmp/ansible-1378470995.11-131618494508055/command
EXEC /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=qlenjvuklluvnzwmqzwwmygmmbbotvln] password: " -u root /bin/sh -c '”’“‘/usr/bin/python /home/mmaas/.ansible/tmp/ansible-1378470995.11-131618494508055/command; rm -rf /home/mmaas/.ansible/tmp/ansible-1378470995.11-131618494508055/ >/dev/null 2>&1’”‘"’’
failed: [taixkaren] => (item=oracle_versions.stdout_lines) => {“changed”: true, “cmd”: "find /opt/oracle/product/oracle_versions.stdout_lines -type d -name admin | grep -i network | egrep -v "11g|filemap" ", “delta”: “0:00:00.017525”, “end”: “2013-09-06 14:36:54.850331”, “item”: “oracle_versions.stdout_lines”, “rc”: 1, “start”: “2013-09-06 14:36:54.832806”}
stderr: find: bad status-- /opt/oracle/product/oracle_versions.stdout_lines
FATAL: all hosts have already failed – aborting

Thanks,
Mark

Are you sure? Because with that change, it fails replacing it as a variable completely:

Yes you are, because it is not:

with_items:

  • oracle_versions.stdout_lines

But it’s:

with_items: oracle_versions.stdout_lines

Ok check!

But I’m still not getting the original problem solved :wink:

This:

  • name: Oracle | Verwijder links/bestanden
    action: file
    state=absent
    dest={{ item[0] }}/{{ item[1] }}
    with_nested:
  • ${oracle_admin_path.stdout_lines}
  • $orafiles
    when: nieuweversiegeplaatst.changed
    tags:
  • orabestanden

Results in:

TASK: [Oracle | Verwijder links/bestanden] ************************************
fatal: [taixkaren] => cannot resolve: ${oracle_admin_path.stdout_lines}
FATAL: all hosts have already failed – aborting

And this:

  • name: Oracle | Verwijder links/bestanden
    action: file
    state=absent
    dest={{ item[0] }}/{{ item[1] }}
    with_nested:
    oracle_admin_path.stdout_lines
    orafiles
    when: nieuweversiegeplaatst.changed
    tags:
  • orabestanden

results in:

TASK: [Oracle | Verwijder links/bestanden] ************************************
fatal: [taixkaren] => cannot resolve: oracle_admin_path.stdout_lines orafiles
FATAL: all hosts have already failed – aborting

Still not getting it :wink:

with_nested:

  • oracle_admin_path.stdout_lines
  • orafiles

You’re missing the “-” before each item in the list.

with_nested:

  • oracle_admin_path.stdout_lines
  • orafiles

You’re missing the “-” before each item in the list.

I’ve tried this as well:

  • name: Oracle | Verwijder links/bestanden
    action: file
    state=absent
    dest={{ item[0] }}/{{ item[1] }}
    with_nested:
  • oracle_admin_path.stdout_lines
  • orafiles
    when: nieuweversiegeplaatst.changed
    tags:
  • orabestanden

But still no luck:

TASK: [Oracle | Verwijder links/bestanden] ************************************
fatal: [taixkaren] => cannot resolve: oracle_admin_path.stdout_lines
FATAL: all hosts have already failed – aborting

Thanks,
Mark

This is hard to debug without seeing your entire playbook structure.

Can you produce a minimal example you can share on github?