Hi
Some of my playbooks involve configuring files in languages such as PHP.
The configuration is basically a large PHP array, for example this SimpleSAMLphp config file:
<?php
$config = array (
'language.i18n.backend' => 'gettext/gettext',
'template.debug' => true,
'baseurlpath' => 'wayf/',
'certdir' => '/etc/simplesamlphp/wayf/cert/',
'logging.handler' => 'file',
'loggingdir' => '/var/log/simplesamlphp/wayf/',
'datadir' => '/var/lib/simplesamlphp/wayf/data/',
'tempdir' => '/tmp/simplesaml-wayf',
'attributenamemapdir' => '/etc/simplesamlphp/wayf/attributemap/',
'secretsalt' => 'secret',
'auth.adminpassword' => 'secret',
'logging.processname' => 'simplesamlphp.wayf',
'language.available' => array('en', 'no', 'nn', 'se', 'da', 'de', 'es', 'sv', 'fi', 'es', 'fr', 'it', 'nl', 'lb', 'cs', 'sl', 'hr', 'hu', 'pl', 'pt', 'pt-BR', 'tr', 'ja', 'zh-tw', 'el', 'lt', 'sam', 'ru'),
'session.cookie.secure' => TRUE,
etc etc
The way I now do this is a template with variables such as:
simplesamlphp_template_debug
simplesamlphp_datadir
simplesamlphp_secretsalt
There are many possible configuration options, so I'm only using a subset as ansible variables.
This doesn't really scale well.
Also, it's not just a simple array, but it can be nested as well (see example above).
I'm looking for a way to configure things in Ansible using the native data structure (yaml), and then templating that out to another language.
So if we consider the above example, you would have this var in a playbook:
config:
language.i18n.backend: gettext/gettext
template.debug: true
baseurlpath: wayf/
certdir: /etc/simplesamlphp/wayf/cert/
logging.handler: file
loggingdir: /var/log/simplesamlphp/wayf/
datadir: /var/lib/simplesamlphp/wayf/data/
tempdir: /tmp/simplesaml-wayf
attributenamemapdir: /etc/simplesamlphp/wayf/attributemap/
secretsalt: secret
auth.adminpassword: secret
language.available:
- en
- no
- nn
- se
- da
- es
- sv
- fi
- fr
- it
logging.processname: simplesamlphp.wayf
session.cookie.secure: TRUE
I was thinking about some way to serialize the yaml data structure and unserialize it using PHP?
But that requires PHP, which is not ideal.
Any ideas on how I can do this?
Many thanks