Hi ,
I have written a simple yaml file to install httpd package
Hi ,
I have written a simple yaml file to install httpd package
Welcome Mallireddy.
Your yaml file is a _role_ and the playbook command requires a _playbook_ as well as an inventory file. You just need to add a playbook (lets call that site.yml) and include your role from above (web.yml).
I tweaked your role a little (use separate lines so that git diffs are easy to read, add a name for readability during playbook runs, and tags to allow targeting tasks easily) but its basically the same as what you already have. I keep all of this together in a single git repo, along with ansible.cfg and hosts inventory file.
Your ansible structure should look like this inside your ansible repo:
# ./site.yml:
---
- hosts: all
roles:
- web
# ./roles/web/tasks/main.yml:
---
- name: ensure web server is installed
yum:
name: httpd
state: installed
tags:
- web
- yum
I use the following a lot - what would the play change, and then actually apply it:
ansible-playbook site.yml --diff -v --check
ansible-playbook site.yml --diff -v
https://github.com/ansible/ansible-examples/tree/master/lamp_simple is a nice simple example pretty close to what you are using - enjoy.
A+
Dave
Boht plays are tasks are lists, you are passing a dictionaries, just
need 1 character to 'fix it'
- hosts: all
tasks:
- yum: "name=httpd state=installed"
^ see the dashes?
That is what 'playbook must be a list of plays' means, if you only fix
- hosts, next would be 'tasks needs to be a list of tasks'.
Your file is still valid YAML, it just does not return the data types
Ansible expects for plays and tasks.