Mike and Uditha,
Ok, I see what you guys are saying about the hosts. I moved it one level up
and now we are getting somewhere. Now, the issue is that it can't run my
task because it doesn't see the value of my conditional. For example, I
want my task to run *when: "{{ testserver }}"*. In other words, I want that
task to run only on the servers in my *testserver *group.
Here is the task/main.yml again:
---
# tasks file for app_install
- name: Install required nfs packages
yum: name={{ item }} state=present
with_items:
- nfs-utils
- nfs-utils-lib
- name: Create a temporary mount point for the installation files
file: path=/tmp/app_install state=directory owner=root group=root mode=0775
- name: Mount the nfs share from nfsshare.domain.tld
shell: mount -F -t nfs -o vers=3 -v nfsshare.domain.tld:/share/location /
tmp/app_install
- name: Install app on test systems
command: /tmp/app_install/apptool_install arg1
when: ({{ testserver }})
- name: Join test systems to test ou
shell: /path/to/domainjoin-cli join --notimesync --disable hostname
--ou OU=test,OU=UNIX,DC=server,DC=domain,DC=tld server.domain.tld
join_account
when: ({{ testserver }})
However, it fails with the following error:
Sudo password:
PLAY [install app and join systems to appropriate ou] ******************
TASK [setup]
*******************************************************************
ok: [testserver1.domain.tld]
TASK [app_install : Install required nfs packages] *********************
changed: [testserver1.domain.tld] => (item=[u'nfs-utils', u'nfs-utils-lib'])
TASK [app_install : Create a temporary mount point for the installation
files] ***
changed: [testserver1.domain.tld]
TASK [app_install : Mount the nfs share] *********************
skipping: [testserver1.domain.tld]
TASK [app_install : Install app on test systems] ***************
fatal: [testserver1.domain.tld]: FAILED! => {"failed": true, "msg": "ERROR!
The conditional check '{{ testserver }}' failed. The error was: ERROR!
error while evaluating conditional ({{ testserver }}): ERROR! 'testserver'
is undefined\n\nThe error appears to have been in
'/git/ansible/projects/app/roles/app_install/tasks/main.yml': line 16,
column 3, but may\nbe elsewhere in the file depending on the exact syntax
problem.\n\nThe offending line appears to be:\n\n\n- name: Install app on
testserver systems\n ^ here\n"}
PLAY RECAP
*********************************************************************
testserver1.domain.tld : ok=3 changed=2 unreachable=0 failed=1
So on my *when: "{{ testserver }}" *for my tasks/main.yml, how do I have it
apply the task only when it matches that host group?
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f403b1e4-66c1-49d0-b4d5-652654e1d3ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.