Ansible hosts

739 views
Skip to first unread message

anil kumar

unread,
Mar 29, 2016, 11:05:46 PM3/29/16
to Ansible Development


When I try playbook I see below error


ok: [resoxapp-ch2f-01c.email.comcast.net]

ERROR! the field 'hosts' is required but was not set


my inventory file

[hosts]

resoxapp-ch2f-01c.email.comcast.net

resoxapp-ch2f-02c.email.comcast.net 

resoxui-ch2f-02c.email.comcast.net

resoxui-ch2f-01c.email.comcast.net

reshaproxy-ch2f-21c.email.comcast.net




Below is the playbook

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


---

# Please pass AUTOUSER (Automation user with ssh key access) and BUILDNAME variables to this script.

- hosts: resoxapp-ch2f-01c.email.comcast.net:resoxui-ch2f-02c.email.comcast.net 

  user: "{{ AUTOUSER }}"

  sudo: yes

# Disable Middlware-01 from UI-02 and UI-01 from haproxy

  tasks:

   - name : Disable the Middleware Host in UserInterface host 

     shell: /var/tmp/en_dis_mw.sh resoxapp-ch2f-01c.email.comcast.net -d

     delegate_to: resoxui-ch2f-02c.email.comcast.net


- hosts: reshaproxy-ch2f-21c.email.comcast.net

  user: "{{ AUTOUSER }}"

  sudo: yes

  vars:

    dc: "{{ DC }}"

  tasks:

   - name : disable UI server from haproxy

     shell : echo "disable server ox_beta_{{dc}}/oxbetaui1" |socat stdio /var/lib/haproxy/stats 

     delegate_to : reshaproxy-ch2f-21c.email.comcast.net


# UPGRADE PLAY

- hosts: resoxapp-ch2f-01c.email.comcast.net 

- name: Upgrade the BETA MIDDLEWARE environment to the specified release

John Buxton

unread,
Mar 30, 2016, 3:40:56 PM3/30/16
to Ansible Development
Your last line is wrong.
"name" attribute must be within a tasks section.

You've put "name" at the same level as "hosts"; ansible-playbook is complaining because it is expecting to see "hosts" at that level.

P.S. This group is for Ansible Development discussions. I believe there's a separate group for Ansible usage issues.

Anand Solomon

unread,
Dec 27, 2019, 2:47:03 PM12/27/19
to Ansible Development
I am getting the same error, and my playbook is as follows. I am trying to run a sql script (record.sql) from the ansible control server to the DB server.

---
- hosts: DBServer
- tasks:
    - name: Execute table.sql using sqlplus
      shell: |
        export ORACLE_HOME={/u01/app/oracle/product/12.2.0.1/dbhome_1}}
        $ORACLE_HOME/bin/sqlplus -s tstsch/tstsch@protegrity @record.sql
      environment:
        ORACLE_HOME: "{{/u01/app/oracle/product/12.2.0.1/dbhome_1}}"
        PATH: "{{$PATH:$ORACLE_HOME/bin}}"
      args:
        chdir: "{{/home/ansible}}"
      become: true
      become_method: su
      become_user: oracle

Karol Czeryna

unread,
Dec 29, 2019, 11:00:46 AM12/29/19
to Anand Solomon, Ansible Development
Hi!

If you remove dash before `tasks` then playbook will run.
What you have right now is another section which is missing hosts field.

Best,
KC
> --
> You received this message because you are subscribed to the Google Groups "Ansible Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/89ad4be1-1a90-44ad-9499-c67dc3907968%40googlegroups.com.

Anand Solomon

unread,
Dec 29, 2019, 11:02:24 PM12/29/19
to Karol Czeryna, Ansible Development
Thank you so much. Have we worked on cx_oracle ansible module? I need some help on that.

Thanks
Anand Solomon

> On Dec 29, 2019, at 11:00 AM, Karol Czeryna <cze...@gmail.com> wrote:
>
> Hi!
Reply all
Reply to author
Forward
0 new messages