1

I am trying to escape single quotes in my terraform script and inventory file.

Terraform script line:

list_compute= "${join("\n",formatlist("%s openshift_node_labels="{'region': 'primary', 'zone': 'east'}"", "${module.compute.ops_compute_names}"))}"

How do I preserve/escape the single quote around region, primary, zone and east?

Also my template file which is used for rendering:

openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}]

How do I preserve/escape the single quotes.

1 Answer 1

0

This should work

join("\n",formatlist("%s openshift_node_labels={'region': 'primary', 'zone': 'east'}", "${module.compute.ops_compute_names}"))

As long as ops_compute_names is a list

4
  • I tried that but terraform still strips off the single quotes Apr 18, 2018 at 9:33
  • After adding \, still getting errors: gist.github.com/infinitydon/e5132c9a1707cc5710cb5b1f867ad6e9 Apr 18, 2018 at 18:13
  • Please any ides why an getting illegal character escape: list_node= "${join("\n",formatlist("%s openshift_node_labels=\"{\'region\': \'infra\', \'zone\': \'default\'}\", "${module.compute.ops_infra_names}"))}" Error running fmt: At 105:144: illegal char escape Apr 20, 2018 at 11:51
  • see the edit to the answer
    – Mike
    Apr 22, 2018 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .