diff --git a/docs/docsite/rst/index.rst b/docs/docsite/rst/index.rst index b35235ff73..38464ed288 100644 --- a/docs/docsite/rst/index.rst +++ b/docs/docsite/rst/index.rst @@ -31,6 +31,7 @@ Ansible, Inc. releases a new major release of Ansible approximately every two mo playbooks_special_topics modules modules_by_category + vault guides dev_guide/index tower diff --git a/docs/docsite/rst/playbooks_vault.rst b/docs/docsite/rst/playbooks_vault.rst index 48eb2dbe6c..6d9afd4b84 100644 --- a/docs/docsite/rst/playbooks_vault.rst +++ b/docs/docsite/rst/playbooks_vault.rst @@ -1,5 +1,5 @@ -Vault -===== +Using Vault in playbooks +======================== .. contents:: Topics @@ -9,86 +9,6 @@ To enable this feature, a command line tool, `ansible-vault` is used to edit fil For best practices advice, refer to :ref:`best_practices_for_variables_and_vaults`. -.. _what_can_be_encrypted_with_vault: - -What Can Be Encrypted With Vault -```````````````````````````````` - -The vault feature can encrypt any structured data file used by Ansible. This can include "group_vars/" or "host_vars/" inventory variables, variables loaded by "include_vars" or "vars_files", or variable files passed on the ansible-playbook command line with "-e @file.yml" or "-e @file.json". Role variables and defaults are also included! - -Ansible tasks, handlers, and so on are also data so these can be encrypted with vault as well. To hide the names of variables that you're using, you can encrypt the task files in their entirety. However, that might be a little too much and could annoy your coworkers :) - -+The vault feature can also encrypt arbitrary files, even binary files. If a vault-encrypted file is given as the `src` argument to the `copy`, `template`, `unarchive`, `script` or `assemble` modules, the file will be placed at the destination on the target host decrypted (assuming a valid vault password is supplied when running the play). - -As of version 2.3, Ansible also supports encrypting single values inside a YAML file, using the `!vault` tag to let YAML and Ansible know it uses special processing. This feature is covered in more details below. - -.. _creating_files: - -Creating Encrypted Files -```````````````````````` - -To create a new encrypted data file, run the following command:: - - ansible-vault create foo.yml - -First you will be prompted for a password. The password used with vault currently must be the same for all files you wish to use together at the same time. - -After providing a password, the tool will launch whatever editor you have defined with $EDITOR, and defaults to vi (before 2.1 the default was vim). Once you are done with the editor session, the file will be saved as encrypted data. - -The default cipher is AES (which is shared-secret based). - -.. _editing_encrypted_files: - -Editing Encrypted Files -``````````````````````` - -To edit an encrypted file in place, use the `ansible-vault edit` command. -This command will decrypt the file to a temporary file and allow you to edit -the file, saving it back when done and removing the temporary file:: - - ansible-vault edit foo.yml - -.. _rekeying_files: - -Rekeying Encrypted Files -```````````````````````` - -Should you wish to change your password on a vault-encrypted file or files, you can do so with the rekey command:: - - ansible-vault rekey foo.yml bar.yml baz.yml - -This command can rekey multiple data files at once and will ask for the original -password and also the new password. - -.. _encrypting_files: - -Encrypting Unencrypted Files -```````````````````````````` - -If you have existing files that you wish to encrypt, use the `ansible-vault encrypt` command. This command can operate on multiple files at once:: - - ansible-vault encrypt foo.yml bar.yml baz.yml - -.. _decrypting_files: - -Decrypting Encrypted Files -`````````````````````````` - -If you have existing files that you no longer want to keep encrypted, you can permanently decrypt them by running the `ansible-vault decrypt` command. This command will save them unencrypted to the disk, so be sure you do not want `ansible-vault edit` instead:: - - ansible-vault decrypt foo.yml bar.yml baz.yml - -.. _viewing_files: - -Viewing Encrypted Files -``````````````````````` - -*Available since Ansible 1.8* - -If you want to view the contents of an encrypted file without editing it, you can use the `ansible-vault view` command:: - - ansible-vault view foo.yml bar.yml baz.yml - .. _running_a_playbook_with_vault: Running a Playbook With Vault @@ -109,7 +29,7 @@ Alternatively, passwords can be specified with a file or a script, the script ve The password should be a string stored as a single line in the file. .. note:: - You can also set ``ANSIBLE_VAULT_PASSWORD_FILE`` environment variable, e.g. ``ANSIBLE_VAULT_PASSWORD_FILE=~/.vault_pass.txt`` and Ansible will automatically search for the password in that file. + You can also set :envvar:`ANSIBLE_VAULT_PASSWORD_FILE` environment variable, e.g. ``ANSIBLE_VAULT_PASSWORD_FILE=~/.vault_pass.txt`` and Ansible will automatically search for the password in that file. If you are using a script instead of a flat file, ensure that it is marked as executable, and that the password is printed to standard output. If your script needs to prompt for data, prompts can be sent to standard error. @@ -118,7 +38,7 @@ This is something you may wish to do if using Ansible from a continuous integrat (The `--vault-password-file` option can also be used with the :ref:`ansible-pull` command if you wish, though this would require distributing the keys to your nodes, so understand the implications -- vault is more intended for push mode). -.. _single_encryptd_variable: +.. _single_encrypted_variable: Single Encrypted Variable ````````````````````````` @@ -135,15 +55,17 @@ As of version 2.3, Ansible can now use a vaulted variable that lives in an other 34623731376664623134383463316265643436343438623266623965636363326136 other_plain_text: othervalue +To create a vaulted variable, use the :ref:`ansible-vault encrypt_string` command. See :ref:`encrypt_string` for details. This vaulted variable will be decrypted with the supplied vault secret and used as a normal variable. The ``ansible-vault`` command line supports stdin and stdout for encrypting data on the fly, which can be used from your favorite editor to create these vaulted variables; you just have to be sure to add the ``!vault`` tag so both Ansible and YAML are aware of the need to decrypt. The ``|`` is also required, as vault encryption results in a multi-line string. -.. _speeding_up_vault: +.. _encrypt_string: -Speeding Up Vault Operations -```````````````````````````` +Using encrypt_string +```````````````````` -By default, Ansible uses PyCrypto to encrypt and decrypt vault files. If you have many encrypted files, decrypting them at startup may cause a perceptible delay. To speed this up, install the cryptography package:: +This command will output a string in the above format ready to be included in a YAML file. +The string to encrypt can be provided via stdin, command line args, or via an interactive prompt. - pip install cryptography +See :ref:`encrypt_string_for_use_in_yaml`. diff --git a/docs/docsite/rst/vault.rst b/docs/docsite/rst/vault.rst new file mode 100644 index 0000000000..536d21b2cb --- /dev/null +++ b/docs/docsite/rst/vault.rst @@ -0,0 +1,413 @@ +Ansible Vault +============= + +.. contents:: Topics + +New in Ansible 1.5, "Vault" is a feature of ansible that allows keeping sensitive data such as passwords or keys in encrypted files, rather than as plaintext in your playbooks or roles. These vault files can then be distributed or placed in source control. + +To enable this feature, a command line tool, :ref:`ansible-vault` is used to edit files, and a command line flag `--ask-vault-pass` or `--vault-password-file` is used. Alternately, you may specify the location of a password file or command Ansible to always prompt for the password in your ansible.cfg file. These options require no command line flag usage. + +For best practices advice, refer to :ref:`best_practices_for_variables_and_vaults`. + +.. _what_can_be_encrypted_with_vault: + +What Can Be Encrypted With Vault +```````````````````````````````` + +The vault feature can encrypt any structured data file used by Ansible. This can include "group_vars/" or "host_vars/" inventory variables, variables loaded by "include_vars" or "vars_files", or variable files passed on the ansible-playbook command line with "-e @file.yml" or "-e @file.json". Role variables and defaults are also included! + +Ansible tasks, handlers, and so on are also data so these can be encrypted with vault as well. To hide the names of variables that you're using, you can encrypt the task files in their entirety. However, that might be a little too much and could annoy your coworkers :) + +The vault feature can also encrypt arbitrary files, even binary files. If a vault-encrypted file is +given as the :ref:`src ` argument to the :ref:`copy `, :ref:`template