-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c2e0b3
commit 812279c
Showing
9 changed files
with
215 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Encrypted values | ||
|
||
Obviously, some value needs to be hidden. This is the case for the ranger admin password. | ||
|
||
HADeploy will allow such value to be encrypted. This can be achived by provided the values as in the following sample: | ||
|
||
```yaml | ||
ranger_relay: | ||
host: en1 | ||
ranger_url: https://ranger.mycluster.mycompany.com:6182 | ||
ranger_username: admin | ||
ranger_password: | | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
34396662613462623565323936616330623661623065343033646136643635653430636238613962 | ||
3537343131346462343138343064313937646366363435340a633532366162623838376436366362 | ||
61393033343932303636653066336130616132383463373934396265306364363562613565613165 | ||
6163613739303430650a356136353865623534643237646166393230613933396166663963633538 | ||
3664 | ||
ca_bundle_local_file: cert/ranger_mycluster_cert.pem | ||
ca_bundle_relay_file: /etc/security/certs/ranger_mycluster_cert.pem | ||
``` | ||
NB: On this version of HADeploy, only the `ranger_password` attribut of [`ranger_relay`](../plugins_reference/ranger/ranger_relay) support this feature. | ||
|
||
## Encrypting a value | ||
|
||
HADeploy encryption rely on the Ansible Vault capability. So, the encryption will be performed using `ansible-vault` commmand. | ||
|
||
Here is a simple approach to achieve this: | ||
|
||
First, create a temporary file containing only the password (Here, the password is `admin`): | ||
|
||
```bash | ||
echo -n admin >/tmp/data.txt | ||
``` | ||
|
||
It is important to ensure there is no leading or trailing control character, or white space: | ||
|
||
|
||
```bash | ||
hexdump -C /tmp/data.txt | ||
00000000 61 64 6d 69 6e |admin| | ||
00000005 | ||
``` | ||
|
||
Then, you can encrypt it, using the following command: | ||
|
||
```bash | ||
ansible-vault encrypt </tmp/data.txt | ||
New Vault password: | ||
Confirm New Vault password: | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
36303764663465323835653063393330393363656263356332383930363039303662663530653561 | ||
3365366637386139333030306638633739653332336363380a623833646435393466386531616230 | ||
36396536633064663736643931313464366166663062663165333362656262626638343532393538 | ||
6562643836373164620a653835383665356233643835613066653261333561333533356638303963 | ||
3266 | ||
Encryption successful | ||
``` | ||
|
||
You will need to provide a Vault password. This is the password you will have to provided later, on each launch of HADeploy. | ||
|
||
Now, you may cut and paste the result as your `ranger_relay.ranger_password` value, as shown on the top of this page. And be sure: | ||
|
||
* Indentation is the same for all lines. | ||
* Indentation is only made of space (No tab). | ||
* There is no space, or white space at the end of the line. | ||
|
||
If you don't follow these recommendation, we may have some cryptic error messages, such as: | ||
|
||
```bash | ||
fatal: [en1]: FAILED! => {"failed": true, "msg": "Unexpected templating type error occurred on ({{ rangerPassword }}): Non-hexadecimal digit found"} | ||
``` | ||
|
||
And, of course, don't forget to cleanup the file which contains the password in clear text. | ||
|
||
``` | ||
rm /tmp/data.txt | ||
``` | ||
NB: The encrypted value is directly provided to Ansible, which will decrypt it in memory, at run time. In other word, HADeploy itself does not perform decryption. So, there is no risk to have a clear password in some intermediate file. | ||
## Launching HADeploy with encrypted values | ||
> Do not mistake this feature with the vault password you may need to provide when accessing an Ansible inventory ([see here](../plugins_reference/ansible_inventories/ansible_inventories)). | ||
There is no relationshipt between these two passwords. They act at different level. | ||
If you launch HADeploy on file containing encrypted value, you will need to provide a password. Otherwise you will have an error like the following: | ||
```bash | ||
The offending line appears to be: | ||
vars: | ||
rangerPassword: !vault | | ||
^ here | ||
``` | ||
|
||
First approach is to enter this password on each launch. For this, simply add the option `--askVaultPassword` on the command line. | ||
|
||
```bash | ||
hadeploy --src infra/mycluster.yml --src app.yml --askVaultPassword --action DEPLOY | ||
.... | ||
Vault password: | ||
``` | ||
|
||
Another approach is to provide this password in a file. The password must be a string stored as a single line of the file. | ||
|
||
Then use the option `--vaultPasswordFile` to provide the path on this file: | ||
|
||
```bash | ||
hadeploy --src infra/mycluster.yml --src app.yml --vaultPasswordFile infra/vault_password.txt --action DEPLOY | ||
``` | ||
|
||
Ensure permissions on the file are such that no one else can access your key and do not add this file to source control. | ||
|
||
|
||
|
||
|
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
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
46 changes: 46 additions & 0 deletions
46
docsite/docs/plugins_reference/ansible_inventories/ansible_inventories.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# ansible_inventories | ||
|
||
## Synopsis | ||
|
||
Provide a list of Ansible Inventory. | ||
|
||
These inventories will be parsed, eventually merged with locally defined [`hosts`](../inventory/hosts) and [`host_groups`](../inventory/host_groups) and will allow target Ansible inventory file generation. | ||
|
||
Also, some paramters may be modified by using [`host_overrides`](../inventory/host_overrides.md) and [`host_group_overrides`](../inventory/host_group_overrides.md). | ||
|
||
## Attributes | ||
|
||
Each item of the list has the following attributes: | ||
|
||
Name | req? | Description | ||
--- | --- | --- | ||
file|yes|The Ansible inventory file path. If this path is not absolute, it will be relative to the HADeploy embedding file location. | ||
vault_password_file|no|If this inventory host one or several encrypted files, one must provide a password for decryption. One method is to provide this password in a file.<br>The password must be a string stored as a single line of the file.<br>If this path is not absolute, it will be relative to the HADeploy embedding file location.<br>It can also be stored in the home folder of the sshd_user by using the ~/... notation.<br>In all cases, ensure permissions on the file are such that no one else can access your key and do not add your this file to source control. | ||
ask_vault_password|no|Boolean. Another method to provide this password is to set this switch on. In this case, the user will be prompted to enter the password on each run. | ||
name|no|Allow to provide a name to this inventory.<br>Useful if this list contains several entries which require a password. This name will be inserted in the prompt for the user. | ||
|
||
|
||
## Example | ||
|
||
```yaml | ||
# This simplest case, with a single inventory | ||
ansible_inventories: | ||
- file: ".../some-ansible-folder/inventory" | ||
|
||
|
||
# Build our own inventory from two Ansible inventories. And request user password with decorated prompt | ||
ansible_inventories: | ||
- name: "inv1" | ||
files: ".../some-ansible-folder/inventory" | ||
ask_vault_password: yes | ||
- name: "inv2" | ||
file: ".../another-ansible-folder/inventory" | ||
ask_vault_password: yes | ||
|
||
``` | ||
## Inventory merging | ||
If a host with same name is defined both in [`hosts`](../inventory/hosts) and in an Ansible inventory, the one from the [`hosts`](../inventory/hosts) list will take precedence. | ||
This is same for the [`host_groups`](../inventory/host_groups). | ||
|
||
Note also a [`host_groups`](../inventory/host_groups) can refer to a host in Ansible inventory. |
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
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
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