I have a pipeline script that takes two parameters, one is a server name, a string parameter TARGET_INSTANCE and the other is a multi-line string parameter LINES.
The pipeline code:
pipeline {
agent any
stages {
stage('Update config file') {
steps {
script {
echo "Update pg_hba.conf on ${env.TARGET_INSTANCE}"
ansiblePlaybook become: true,
colorized: true,
credentialsId: 'user_cred',
extras: "-e target_instance=${env.TARGET_INSTANCE} -e lines=${LINES}",
installation: 'ansible',
inventory: 'etc/ansible/hosts',
playbook: "google/ansible/update_conf.yml"
}
}
}
}
}
Part of the update_conf.yml looks like this:
- name: Update config.conf
ansible.builtin.blockinfile:
state: present
dest: /etc/pgsql/config.conf
block: |
{{ lines }}
If I give the multi-line parameter values like:
111111111
2222222
333333333
44444444
The script update_conf.yml only appends the /etc/pgsql/config.conf with the first line 111111111 and ignores the rest of the 3 lines. If I give the multi-line parameter values like:
111111111\n2222222\n333333333\n44444444
The script update_conf.yml will append the /etc/pgsql/config.conf with all 4 lines as expected.
Is there anyway that I can use
111111111
2222222
333333333
44444444
to update the config.conf with all 4 lines?
Thanks!