Edit json file using ansible
up vote
0
down vote
favorite
I am trying to edit a particular JSON file using Ansible. The file is present in remote servers which have to be logged in using LDAP authentication.
The file path is /etc/sensu/conf.d/client.json
and the line that I want to edit is as follows:
"subscriptions": ["Nginx", "Primus", "B2B", "Docker_Process_Check", "EBS", "base"],
I want to add one more value ("filebeat"
) in that line which after that should look like
"subscriptions": ["Nginx", "Primus", "B2B", "Docker_Process_Check", "EBS", "base","filebeat"],
ansible file-manipulation
New contributor
add a comment |
up vote
0
down vote
favorite
I am trying to edit a particular JSON file using Ansible. The file is present in remote servers which have to be logged in using LDAP authentication.
The file path is /etc/sensu/conf.d/client.json
and the line that I want to edit is as follows:
"subscriptions": ["Nginx", "Primus", "B2B", "Docker_Process_Check", "EBS", "base"],
I want to add one more value ("filebeat"
) in that line which after that should look like
"subscriptions": ["Nginx", "Primus", "B2B", "Docker_Process_Check", "EBS", "base","filebeat"],
ansible file-manipulation
New contributor
What did you try so far? What is your operating system?
– Laurenz Albe
19 hours ago
It is mac os..But I am trying to update the same in multiple ec2 linux instances..I was trying with lineinfile inbuilt module but that does not work for json I guess..Any inbuilt module present for doing the same.
– Antarjyoti Sen
17 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to edit a particular JSON file using Ansible. The file is present in remote servers which have to be logged in using LDAP authentication.
The file path is /etc/sensu/conf.d/client.json
and the line that I want to edit is as follows:
"subscriptions": ["Nginx", "Primus", "B2B", "Docker_Process_Check", "EBS", "base"],
I want to add one more value ("filebeat"
) in that line which after that should look like
"subscriptions": ["Nginx", "Primus", "B2B", "Docker_Process_Check", "EBS", "base","filebeat"],
ansible file-manipulation
New contributor
I am trying to edit a particular JSON file using Ansible. The file is present in remote servers which have to be logged in using LDAP authentication.
The file path is /etc/sensu/conf.d/client.json
and the line that I want to edit is as follows:
"subscriptions": ["Nginx", "Primus", "B2B", "Docker_Process_Check", "EBS", "base"],
I want to add one more value ("filebeat"
) in that line which after that should look like
"subscriptions": ["Nginx", "Primus", "B2B", "Docker_Process_Check", "EBS", "base","filebeat"],
ansible file-manipulation
ansible file-manipulation
New contributor
New contributor
edited 14 hours ago
James Z
11.1k71735
11.1k71735
New contributor
asked 19 hours ago
Antarjyoti Sen
1
1
New contributor
New contributor
What did you try so far? What is your operating system?
– Laurenz Albe
19 hours ago
It is mac os..But I am trying to update the same in multiple ec2 linux instances..I was trying with lineinfile inbuilt module but that does not work for json I guess..Any inbuilt module present for doing the same.
– Antarjyoti Sen
17 hours ago
add a comment |
What did you try so far? What is your operating system?
– Laurenz Albe
19 hours ago
It is mac os..But I am trying to update the same in multiple ec2 linux instances..I was trying with lineinfile inbuilt module but that does not work for json I guess..Any inbuilt module present for doing the same.
– Antarjyoti Sen
17 hours ago
What did you try so far? What is your operating system?
– Laurenz Albe
19 hours ago
What did you try so far? What is your operating system?
– Laurenz Albe
19 hours ago
It is mac os..But I am trying to update the same in multiple ec2 linux instances..I was trying with lineinfile inbuilt module but that does not work for json I guess..Any inbuilt module present for doing the same.
– Antarjyoti Sen
17 hours ago
It is mac os..But I am trying to update the same in multiple ec2 linux instances..I was trying with lineinfile inbuilt module but that does not work for json I guess..Any inbuilt module present for doing the same.
– Antarjyoti Sen
17 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
AFAIK there's still no builtin module for JSON manipulation.
Either use 3rd-party module (like ghetto-json),
or make a complex regular expression with replace module (i.e. search for "subscriptions": [<...>]
and place ,"filebeat"
just before closing ]
. You can use regex101.com to craft and test required expression.
Please also inspect this answer for additional info.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
AFAIK there's still no builtin module for JSON manipulation.
Either use 3rd-party module (like ghetto-json),
or make a complex regular expression with replace module (i.e. search for "subscriptions": [<...>]
and place ,"filebeat"
just before closing ]
. You can use regex101.com to craft and test required expression.
Please also inspect this answer for additional info.
add a comment |
up vote
0
down vote
AFAIK there's still no builtin module for JSON manipulation.
Either use 3rd-party module (like ghetto-json),
or make a complex regular expression with replace module (i.e. search for "subscriptions": [<...>]
and place ,"filebeat"
just before closing ]
. You can use regex101.com to craft and test required expression.
Please also inspect this answer for additional info.
add a comment |
up vote
0
down vote
up vote
0
down vote
AFAIK there's still no builtin module for JSON manipulation.
Either use 3rd-party module (like ghetto-json),
or make a complex regular expression with replace module (i.e. search for "subscriptions": [<...>]
and place ,"filebeat"
just before closing ]
. You can use regex101.com to craft and test required expression.
Please also inspect this answer for additional info.
AFAIK there's still no builtin module for JSON manipulation.
Either use 3rd-party module (like ghetto-json),
or make a complex regular expression with replace module (i.e. search for "subscriptions": [<...>]
and place ,"filebeat"
just before closing ]
. You can use regex101.com to craft and test required expression.
Please also inspect this answer for additional info.
answered 19 hours ago
Konstantin Suvorov
34.6k43676
34.6k43676
add a comment |
add a comment |
Antarjyoti Sen is a new contributor. Be nice, and check out our Code of Conduct.
Antarjyoti Sen is a new contributor. Be nice, and check out our Code of Conduct.
Antarjyoti Sen is a new contributor. Be nice, and check out our Code of Conduct.
Antarjyoti Sen is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222124%2fedit-json-file-using-ansible%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What did you try so far? What is your operating system?
– Laurenz Albe
19 hours ago
It is mac os..But I am trying to update the same in multiple ec2 linux instances..I was trying with lineinfile inbuilt module but that does not work for json I guess..Any inbuilt module present for doing the same.
– Antarjyoti Sen
17 hours ago