How to save ansible stdout.lines to a file is in list format

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Need help in saving std.out lines to a file in delegated host using below playbook.
I am able to save the data, but the saved data is in json format. I need this data as list format as like command output.
- name: Host Collection
hosts: rcht01
tasks:
- name: Host coll
shell: mysql -ulnx -plnx -D inventory -se "select Host_Name from servers where OS= 'Linux' AND Server_Status = 'Live' AND Server_loc = 'Richardson' "| tr 'A-Z' 'a-z'
register: all_hosts_list
- name: Saving data to local file
copy:
content: " all_hosts_list.stdout_lines "
dest: /tmp/host_coll
delegate_to: rchabs01
ansible
add a comment |Â
up vote
1
down vote
favorite
Need help in saving std.out lines to a file in delegated host using below playbook.
I am able to save the data, but the saved data is in json format. I need this data as list format as like command output.
- name: Host Collection
hosts: rcht01
tasks:
- name: Host coll
shell: mysql -ulnx -plnx -D inventory -se "select Host_Name from servers where OS= 'Linux' AND Server_Status = 'Live' AND Server_loc = 'Richardson' "| tr 'A-Z' 'a-z'
register: all_hosts_list
- name: Saving data to local file
copy:
content: " all_hosts_list.stdout_lines "
dest: /tmp/host_coll
delegate_to: rchabs01
ansible
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Need help in saving std.out lines to a file in delegated host using below playbook.
I am able to save the data, but the saved data is in json format. I need this data as list format as like command output.
- name: Host Collection
hosts: rcht01
tasks:
- name: Host coll
shell: mysql -ulnx -plnx -D inventory -se "select Host_Name from servers where OS= 'Linux' AND Server_Status = 'Live' AND Server_loc = 'Richardson' "| tr 'A-Z' 'a-z'
register: all_hosts_list
- name: Saving data to local file
copy:
content: " all_hosts_list.stdout_lines "
dest: /tmp/host_coll
delegate_to: rchabs01
ansible
Need help in saving std.out lines to a file in delegated host using below playbook.
I am able to save the data, but the saved data is in json format. I need this data as list format as like command output.
- name: Host Collection
hosts: rcht01
tasks:
- name: Host coll
shell: mysql -ulnx -plnx -D inventory -se "select Host_Name from servers where OS= 'Linux' AND Server_Status = 'Live' AND Server_loc = 'Richardson' "| tr 'A-Z' 'a-z'
register: all_hosts_list
- name: Saving data to local file
copy:
content: " all_hosts_list.stdout_lines "
dest: /tmp/host_coll
delegate_to: rchabs01
ansible
edited May 18 at 18:30
asked May 18 at 18:13
Pandu
2616
2616
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2funix.stackexchange.com%2fquestions%2f444677%2fhow-to-save-ansible-stdout-lines-to-a-file-is-in-list-format%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