I am creating a role to install some packages and then join a system to a 
domain controller. However, when I run my playbook, it comes back saying 
*ERROR! 
ERROR! 'test' is undefined.* Here is how I am running my playbook:

ansible-playbook -i server_hosts app_install_main.yml 


I don't see where I need to define my host properly. My role consist of the 
following files:

├── server_hosts
├── app_install
│   ├── README.md
│   ├── defaults
│   │   └── main.yml
│   ├── files
│   ├── handlers
│   │   └── main.yml
│   ├── meta
│   │   └── main.yml
│   ├── tasks
│   │   └── app_install_task.yml
│   ├── templates
│   ├── tests
│   │   ├── inventory
│   │   └── test.yml
│   └── vars
│       └── main.yml
├── app_install_main.yml

My app_install_task.yml contains the following:

---
# 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: ({{ test }})

- 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: ({{ test }})

 My app_install_main.yml (task file) looks like this:

---

- name: install app and join systems to domain
  hosts: "{{ test }}"
  become: yes

  roles:
    - app_install

  vars_prompt:
    - name: "ansible_sudo_pass"
      prompt: "Sudo password"
      private: yes

My app_hosts file looks like this:

[testsystems]
testserver1.domain.tld

[developmentsystems]
devserver1.domain.tld
devserver2.domain.tld

[productionsystems]
prodserver1.domain.tld
prodserver2.domain.tld

[testservers:children]
testsystems

[dev-servers:children]
developmentsystems

[prod-servers:children]
productionsystems

And here is what I have in my vars/main.yml:

---
# vars file for app_install

test: "{{ testservers }}"

Where or how should I define my host? This is my first role. I am sure I am 
missing a few obvious requirements.

-- 
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/7fcac4db-6c32-4473-8ae6-82526b498ae3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to