Package: vaultfly
# vaultflyAnsible login automation using ansible vault with templating and password tokens## What- vaultfly is for automating ssh login when you need to use a token## Install```bashpip install vaultfly --user```## Tokens (the hard part)- To generate the token, you need access to the token definition file.- Most likely you dont have access to that.- The work arround is to generate your own and use that.- I use 'python-vipaccess2'. It will generate a Symantec compatible token- pip install python-vipaccess2 or pipenv....- instructions can be found at https://github.com/chris17453/vipaccessUI## Help```bash$ vaultflyusage: vault-fly [-h] [-i] [-b] [-r] [-v VAULT_FILE] [-vt VAULT_TEMPLATE][-c CONFIG_FILE] [-p PASSWORD_FILE] [-t] [-sc] [-sv] [-vvv]Create ansible vault login credentials on the fly.optional arguments:-h, --help            show this help message and exitCommands:-i, --init            init user config-b, --build           build a new vault file-r, --random-pass     generate a random password and save it to the passwordfileConfig:-v VAULT_FILE, --vault-file VAULT_FILElogin vault file to create-vt VAULT_TEMPLATE, --vault-template VAULT_TEMPLATEcreate vault file with this template-c CONFIG_FILE, --config-file CONFIG_FILEuser config created from 'init'-p PASSWORD_FILE, --password-file PASSWORD_FILEsingle line text file with used for vault password-t, --token           use token with password in (password+token)Display:-sc, --show-config    view config file-sv, --show-vault     view vault file-vvv, --verbose       Display more execution info```## Walkthrough```bash# create a user config with a random password file[test]$  vaultfly -i -p test.pass -c test.configPassword file is invalid, Create random password? [y/N] yEnter SSH credentials that anssible will connect with:User [nd]:chris17453Password:# view password file[test]$ cat test.passiroen@yh#Ts5fV04*BWcvRFj$HLDazZd# view config file[test]$ cat test.config$ANSIBLE_VAULT;1.1;AES256626333616561653832323536303038643435316635303731313233636235353233623335646164626137633635313839303137363965656262376238643238310a356432313061333863363737613939646565373265326235316338336639333635343165303837306465393038653337653532666434373463383330663731330a343231323139613062333462633865636463643234643634636238316562656331353866363564386634346335386532393037323337323166356364663362633531623364343332376162626231653630336636303734333035636538386236# create new vault file on the fly[test]$  vaultfly -b -p test.pass -c test.config -v test.vault# view test vault[test]$  cat test.vault$ANSIBLE_VAULT;1.1;AES256343337356537663733613839636430376662346262316134616331666233346137313630636236663763343062333337653637303736363061623962373762610a613632393335666565333633663333376134306539366632303463646438666162393262353062623734323233663163376339653836633361363535343661350a323266353536626635666364376432303966326635626464383565323763333262393038633935663964643964386635333163366232373538623637343737323666663964333565666531316330666261336330633838316364376266653762336465353333346637653766326161326535316331366661663332323861316436303731613165333638663463363262396630633534316532306261656134316232353363346131393336316236653134353131393339316530623265343163#show decrypted vault[test]$ vaultfly -p test.pass -c test.config -v test.vault -svansible_connection: sshansible_ssh_pass: mypasswordansible_ssh_user: chris17453# display template for next example[test]$ cat template.vaultbob: 4324# create vault on the fly with token using a template# display unencrypted vault file (the display option is for convienence)[test]$ vaultfly -b  -p test.pass \-c test.config \-v test.vault \-vt template.vault \-tansible_connection: sshansible_ssh_pass: mypassword803883ansible_ssh_user: chris17453bob: 4324```## How to use with ansible?- First I created a template called tpl.vault```yamlansible_become: trueansible_become_method: suansible_user: 'user'ansible_become_exe: 'sudo  su -'```- Next then made an inventory - > inventory.ini```yaml[test]test-box1.com.internaltest-box2.com.internal```- Then I made an ansible play -> copy.yaml```yaml---- hosts: testgather_facts: Falsetasks:- name: Copy stuff if this is -> test-box1.com.internalcopy:src: ../code/dest: /tmp/placetoputstuffowner: usergroup: groupwhen: inventory_hostname == "test-box1.com.internal"- name: Copy stuff if this is -> test-box2.com.internalcopy:src: ../code/dest: /tmp/different_placetoputstuffowner: usergroup: groupwhen: inventory_hostname == "test-box2.com.internal"```- Finally I run the play everytime I want to upload some files```bash#build a new vault with a tokenvaultfly -b -t -vt tpl.vault -p my-pass-file -c my-config-file -v group_vars/all# run the playansible-playbook -i inventory.ini copy.yaml```## updates- I will make updates as required giving time## notes- 'make standalone' will build no dependency executable in "dist/"