Running a simple playbook

I'm running my first playbook:

- hosts: CL400
  user: jmarcus
  sudo: True

- name: no iptables
  action: service name=iptables state=stopped

ERROR: action is not a legal parameter in an Ansible Playbook

if the service stat was already stopped would I get this message? Or
is this really related to "action"

Thanks,
James

James:

You’re missing “tasks:”. Try this:

  • hosts: CL400
    user: jmarcus
    sudo: True

tasks:

  • name: no iptables
    action: service name=iptables state=stopped

Take care,

Lorin

Thanks, that gets me a little further, but I get: ERROR: hosts
declaration is required

Do I need hosts after tasks?

- hosts: CL400
  user: jmarcus
  sudo: True

- tasks:

- name: no nfslock
  action: service name=nfslock state=stopped enabled=no

Thanks,
James

Absolutely.

Please see the examples directory in the git checkout.

examples/playbooks/*

all of these are valid playbook syntax.

James:

You do, indeed, need to specify hosts. Also, don’t put the “-” before tasks.

Take care,

Lorin

Ok thats what I don't understand, I feel like I have read most of
these examples. Who do I get the hosts message?
Isn't my first line legitimate?

- hosts: CL400
  user: jmarcus
  sudo: True

  tasks:

- name: no nfslock
  action: service name=nfslock state=stopped enabled=no

and when I try to run with out - tasks it fails with:

expected <block end>, but found '?'
  in "<string>", line 18, column 1:
    tasks:
    ^

James:

I think you’re running into whitespace problems. YAML files are sensitive to indentation. Try doing a copy-paste of this:

  • hosts: CL400
    user: jmarcus
    sudo: True

tasks:

  • name: no nfslock
    action: service name=nfslock state=stopped enabled=no

Take care,

Lorin

Thanks Lorin this worked!

James

Hello everyone,

we have use cloudformation to create a stack in aws. We are now trying to figure out how to get the actual edx platform code to deploy and run on those newly configured servers. We have figured out we have to run main.yml in playbooks/roles/edxapp/tasks/ to have the code deploy on the servers, but we get:

ERROR: file is not a legal parameter in an Ansible Playbook

when running the command: ansible-playbook -vvv ~/repos/edx-configuration/playbooks/roles/edxapp/tasks/main.yml -e ‘region=eu-west-1 key=edX name=edx-configuration’

Any advice would be extremely appreciated!!

Thanks to all

Hello everyone,

we have use cloudformation to create a stack in aws. We are now trying to
figure out how to get the actual edx platform code to deploy and run on
those newly configured servers. We have figured out we have to run main.yml
in playbooks/roles/edxapp/tasks/ to have the code deploy on the servers,
but we get:

*ERROR: file is not a legal parameter in an Ansible Playbook*

when running the command: * **ansible-playbook -vvv
~/repos/edx-configuration/playbooks/roles/edxapp/tasks/main.yml -e
'region=eu-west-1 key=edX name=edx-configuration'*

I'm assuming you're using the main.yml from this :
https://github.com/edx/configuration/blob/master/playbooks/roles/edxapp/tasks/main.yml

What's happening here is that you're attempting to run a role as a full
playbook, but that's not exactly how it works. The tasks in roles are not
full plays, but rather a list of actions. The reason you're getting the
error about "file" is because Ansible doesn't know you're attempting to run
tasks yet.

What you can do instead is build a play that uses the role.
http://www.ansibleworks.com/docs/playbooks.html#roles By just creating a
wrapper play, you should be able to get around this error.