Last active
September 22, 2016 18:10
-
-
Save goreilly/ea93027c058659c5fb233a78ffae2d95 to your computer and use it in GitHub Desktop.
ansible generate symfony parameters.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"symfony/yaml": "2.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- copy: | |
remote_src: yes | |
src: "/var/www/project/app/config/parameters.yml.dist" | |
dest: "/var/www/project/app/config/parameters.yml" | |
force: no | |
owner: '{{ web_user }}' | |
group: '{{ web_group }}' | |
mode: 0660 | |
- with_dict: '{{ parameters }}' | |
lineinfile: | |
dest: "/var/www/project/app/config/parameters.yml" | |
line: ' {{ item.key }}: {{ lookup("pipe", role_path ~ "/inline_yaml.php " ~ item.value) }}' | |
regexp: '^ {{ item.key }}:' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
/** | |
* This is the same tool symfony uses to convert the parameter file values. | |
* We can use this so symfony won't change our parameters again after we set them. | |
*/ | |
use Symfony\Component\Yaml\Inline; | |
require_once __DIR__.'/../../vendor/autoload.php'; | |
if ($argc !== 2) { | |
echo 'Usage: inline_yaml.php INPUT'; | |
return 1; | |
} | |
$input = $argv[1]; | |
// ansible booleans | |
switch (strtolower($input)) { | |
case 'yes': | |
$input = 'true'; | |
break; | |
case 'no': | |
$input = 'false'; | |
break; | |
} | |
$value = Inline::parse($input); | |
if (is_bool($value)) { | |
$value = $value ? 'true' : 'false'; | |
} | |
echo $value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment