I have a configuration file that contains a list of string variables that the user is required to change to suit their environment:
Configuration file example:
# first_file.yml
value_one: <UPDATE>
value_two: <UPDATE>
# second_file.yml
value_one: <UPDATE>
value_two: <UPDATE>
Once the user has changed the UPDATE value, I want to be able to use vault to encrypt each variable before copying the encrypted variable to a file specified in the comment, with the desired out below:
# first_file.yml
value_one: !vault |
$ANSIBLE_VAULT;1.1;AES256
30663734346135353432323531336536636566643739656332613031636630383237666636366630
6164633835363766666535656438306534343565636434330a626239396536373032373866353861
37376665313438363561323262393337313266613237313065396338376438313737393234303434
3035326633616339340a346164646366623932313261613662633938356662373438643831643830
3432
value_two: !vault |
$ANSIBLE_VAULT;1.1;AES256...
I am unsure how to best approach this problem, with the main challenge being how to:
- Encrypt each variable successfully, without encrypting the entire file
- Copy the encrypted variable over to a specified file