Karther
(Karther)
December 10, 2019, 2:20pm
1
Hey Community ansible !!
I have some line texte with this content :
my first line
my second line
my 3ème line
my 4ème line
I want register all this line with one variable ? i don’t know if possible or not please ???
Can you help me please Community Ansible ?
Best regards,
Karther
racke
(Stefan Hornburg)
December 10, 2019, 3:15pm
2
Hey Community ansible !!
I have some line texte with this content :
my first line
my second line
my 3ème line
my 4ème line
I want register all this line with one variable ? i don't know if possible or not please ???
Can you help me please Community Ansible ?
Best regards,
Karther
Sorry I have no idea what you want to achieve.
Regards
Racke
Karther
(Karther)
December 10, 2019, 3:32pm
3
Hey,
I want register some line in one variable …
I have some line :
my first line
my second line
my 3ème line
my 4ème line
I want that my variable =
my first line
my second line
my 3ème line
my 4ème line
Thanks for your help !!
Regards,
j1f0x
(j1f0x)
December 12, 2019, 9:48pm
4
Hi,
maybe you try this:
include_newlines: |
exactly as you see
will appear these three
lines of poetry
fold_newlines: >
this is really a
single line of text
despite appearances
see: https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
Karther
(Karther)
December 31, 2019, 8:34am
5
Hey,
no I have this result with this task :
“msg”: “exactly as you see\nwill appear these three\nlines of poetry\n”
Can you help me please ??
Thanks very much,
Best Regards,
Karther
vbotka
(Vladimir Botka)
December 31, 2019, 9:26am
6
The playbook below is self-explaining
- hosts: localhost
vars:
msg: |
exactly as you see
will appear these three
lines of poetry
tasks:
- debug:
msg: "{{ msg }}"
- debug:
msg: "{{ msg.split('\n') }}"
- debug:
msg: "{{ msg.split('\n')[:-1] }}"
gives
ok: [localhost] => {
"msg": "exactly as you see\nwill appear these three\nlines of poetry\n"
}
ok: [localhost] => { "msg": [
"exactly as you see",
"will appear these three",
"lines of poetry",
""
]
}
ok: [localhost] => { "msg": [
"exactly as you see",
"will appear these three",
"lines of poetry"
]
}
HTH,
-vlado