ansible playbook in json format not working

Hello Folkds:

Thank you in advance for your time and attention.

I wrote a playbook in the json format.

[
{
“name”: “Test the json mode”
“hosts”: “cool_columbus”,
“tasks”: [
{
“name”: “First task”
“shell”: {
“chdir”: “/tmp”,
“free_form”: “ls -l”,
}
}
]
}
]

when I run it with the command

ansible-playbook test_playbook.json

ERROR! Syntax Error while loading YAML.

expected ‘,’ or ‘}’, but got ‘’

The error appears to have been in ‘/home/pidansible/test_playbook.json’: line 4, column 5, but may

be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

What am I doing wrong and how to run this ?

Please help.

-N

Playbooks must be in yaml. Inventories can be in json (at least dynamic inventories require it), but not the playbooks themselves.

Hello Folkds:

Thank you in advance for your time and attention.

I wrote a playbook in the json format.

> [
> {
> "name": "Test the json mode"

Missing a comma.

> "hosts": "cool_columbus",
> "tasks": [
> {
> "name": "First task"

Missing comma.

> "shell": {
> "chdir": "/tmp",
> "free_form": "ls -l",
> }
> }
> ]
> }
> ]

when I run it with the command

>> ansible-playbook test_playbook.jsonERROR! Syntax Error while loading YAML. expected ',' or '}', but got '<scalar>'
>> The error appears to have been in '/home/pidansible/test_playbook.json': line 4, column 5, but maybe elsewhere in the file depending on the exact syntax problem.
>> The offending line appears to be:

What am I doing wrong and how to run this ?

Please help.

-N

V/r,
James Cassell

Thank You James for pointing out the mistakes.

I fixed them and now the json playbook works.

James pointed out the mistakes in the json and now it works.
I am able to use json as valid format for playboks.

Just for curiosity, why are you using json instead of yaml?

JSON is a subset of YAML, so anything you see in YAML can be done in
JSON, .. the real question is SHOULD YOU?