Giter Club home page Giter Club logo

vault-boshrelease's Introduction

Vault - Secure Credentials Storage

NOTE: This BOSH release has a lot of configuration options, and is intended more for people who want to tinker with Vault and its various storage backends. If you are looking for a rock-solid Vault deployment on BOSH, check out the safe BOSH Release instead.

Questions? Pop in our slack channel

This BOSH release packages the excellent Vault software from Hashicorp, primarily for tinkering, experimentation.

  • Release engineering and testing by Stark & Wayne Concourse
  • All PRs will be run through CI/CD (see testflight-pr job)

Usage

To use this BOSH release:

$ export BOSH_ENVIRONMENT=<alias>
$ export BOSH_DEPLOYMENT=vault

$ git clone https://github.com/cloudfoundry-community/vault-boshrelease.git
$ cd vault-boshrelease
$ bosh deploy manifests/vault.yml --vars-store tmp/creds.yml

If your BOSH has Credhub/Config Server, then you do not need --vars-store. Rather certificates/credentials will be generated and stored within Credhub. Subsequent instructions below will continue to use --vars-store examples.

Run bosh instances to get the IP address for one of your Vault instances:

$ bosh instances

Instance                                    Process State  AZ  IPs
vault/259fbc67-0a0f-4714-a122-f3370ffd5bd6  running        z3  10.244.0.187
vault/5a692a5e-260a-414f-9906-6e1ccbf66433  running        z2  10.244.0.186
vault/9f34f839-92a0-4827-a713-c43a2430c0d9  running        z1  10.244.0.185

Next you need to initialize the Vault. Connect via port :8200:

$ export VAULT_ADDR=https://10.244.0.187:8200
$ export VAULT_SKIP_VERIFY=true
$ vault operator init

This generates a root encryption key for encrypting all of the secrets. At this point, the vault is sealed, and you will need to unseal it three times, each time with a different key:

$ vault operator unseal
$ vault operator unseal
$ vault operator unseal

Once unsealed, your Vault should be ready for authentication with your initial root token:

$ vault login

Now, you can put secrets in the Vault, and read them back out (try any path with secret/ prefix):

$ vault write secret/handshake knock=knock
$ vault read secret/handshake

You may want to look at safe, an alternative command-line utility for Vault that provides higher-level abstractions like tree-based listing, secret generation, secure terminal password entry, etc.

Configuration

Template Strings

As the base manifest shows, a full HCL configuration can be assigned to the vault.config property. If you're using Vault in HA mode (which is recommended) you'll probably need to set values like api_addr and cluster_address. The vault.config property supports the following template strings to make setting these values easier:

(ip)

During deployment this value will be replaced with the IP address of the instance. This will not include the protocol or any port information. For example for an IP based configuration:

storage "consul" {
  path = "vault/"
  check_timeout = "5s"
  max_parallel = "128"
}
api_addr = "http://(ip):8200"
cluster_addr = "https://(ip):8201"

(index)

During deployment this value will be replaced with the index of the instance. This can be particularly useful for DNS configuration values. For example, if you were deploying 3 instances, this would ensure each one had a unique DNS value in its configuration::

storage "consul" {
  path = "vault/"
  check_timeout = "5s"
  max_parallel = "128"
}
api_addr = "http://vault-(index).yoursite.biz:8200"
cluster_addr = "https://vault-(index).yoursite.biz:8201"

Certificate Management

Your Vault configuration is likely going to require TLS. This release's vault.tls property can lets you provide these certificates:

properties:
  tls:
    - name: "my_tls_cert"
      cert: |
        -----BEGIN CERTIFICATE-----
        CertBlockAsRawText
        -----END CERTIFICATE-----
      key: ((or_use_a_variable))

    - name: "other_tls_cert"
      cert: ((other_tls_certificate_content))
      key: ((other_tls_key_content))

The above configuration will create the following files on the Vault instance before starting Vault:

  • /var/vcap/jobs/vault/tls/my_tls_cert/cert.pem
  • /var/vcap/jobs/vault/tls/my_tls_cert/key.pem
  • /var/vcap/jobs/vault/tls/other_tls_cert/cert.pem
  • /var/vcap/jobs/vault/tls/other_tls_cert/key.pem

Management of Additional Configuration Files

Vault's configuration supports lots of cool features that sometimes require additional configuration files be present. An example of this is GCP auto unsealing. To support these kinds of cases this Bosh release provides the additional_config property.

properties:
  vault:
    additional_config:
      - name: gcp.json
        config: |
          {
            "some":"valid_json"
          }

The above configuration will create the file /var/vcap/jobs/vault/config/gcp.json on the Vault instance before starting Vault.

Monit Script Configuration

In order to enable features like zero downtime redeploys this Bosh release bundles scripts that utilize the Vault CLI. Manifest properties are available to explicitly set the value of the VAULT_SKIP_VERIFY and VAULT_ADDR environment variables in the context of these monit scripts:

  properties:
    vault:
      skip_verify: false                      #default if absent
      addr:        "https://127.0.0.1:8200"   #default if absent

Prior to 1.0.0 release, the VAULT_SKIP_VERIFY environment variable is set if the vault address contains https, so connecting to the vault server on 127.0.0.1 (during unseal) would not throw an SSL exception. Since 1.0.0 release, the environmental variable is no longer set by default. There are several possible ways to address the situation.

  • If you have only one vault node, you can use properties.vault.addr to set VAULT_ADDR environmental variable according to your cert CN.

  • If you have more than one nodes, and can use SAN IP entry of 127.0.0.1 in your certs, leave out properties.vault.addr (using the default).

  • If you have more than one nodes, and can NOT use SAN IP entry of 127.0.0.1 in your certs, you need to specify vault.skip_verify, and leave out vault.addr. This breaks the security model, though minor since the communication is at the local host.

Zero Downtime Updates

To enable zero-downtime updates you must provide an auth token that is authorized to perform vault step-down. Once you have unsealed vault you can set it up as follows:

$ cat > step-down.hcl <<EOF
path "sys/step-down" {
  capabilities = ["update", "sudo"]
}
EOF

$ vault policy write step-down ./step-down.hcl
Policy 'step-down' written.
$ vault token create -policy="step-down" -display-name="step-down" -no-default-policy -orphan
Key             Value
---             -----
token           STEP-DOWN-TOKEN
token_accessor  cf37c98a-685a-1cf0-fc2e-4bd21a4a6be2
token_duration  768h0m0s
token_renewable true
token_policies  [step-down]

Then add the token value to your deployment file under properties.vault.update.step_down_token. This will cause Vault to perform a controlled failover before updating each individual node.

Once the update of a node has completed it will need to be unsealed. If you add your unseal keys under properties.vault.update.unseal_keys this will also be taken care of. This will make the entire update process truely zero-downtime ie. when using a consul-agent to provide dns, the domain name vault.service.consul should always be pointing to a Vault that will accept connections.

$ bosh deploy manifests/vault.yml --vars-store tmp/creds.yml \
  -o manifests/operators/step-down-token.yml \
  -v "vault-step-down-token=STEP-DOWN-TOKEN" \
  -v "vault-unseal-keys=[UNSEAL1,UNSEAL2,UNSEAL3]"

It is highly recommended to run vault rekey after an update where the unseal keys were provided have taken place to not leave the keys exposed in the manifest.

WARNING!!! If you add the unseal keys to your manifest and do not rekey once the deployment is done then it will be possible for anyone with access to the manifest to decrypt and see all secrets stored in vault.

You will provide three of the original unseal keys to vault rekey, so run it three times to generate new unseal keys:

$ vault operator rekey
$ vault operator rekey
$ vault operator rekey

See rekeying and rotating (in the Vault documentation) for additional instructions.

vault-boshrelease's People

Contributors

alexvianet avatar atulkc avatar bonzofenix avatar cjnosal avatar datianshi avatar daviddob avatar dennisjbell avatar drnic avatar geofffranks avatar infra-red avatar jhunt avatar joek avatar johnlonganecker avatar lnguyen avatar making avatar maruku0 avatar mattsurabian avatar mkb avatar mkuratczyk avatar norman-abramovitz avatar ntdt avatar paweloczadly avatar ramonskie avatar simonjohansson avatar soutenniza avatar tlwr avatar wayneeseguin avatar ywei2017 avatar z4ce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vault-boshrelease's Issues

Support for Vault 1.13

Hi team,

This BOSH release is still in use on a project I'm currently work on and we'd really benefit from support for Vault 1.13. Are there any plans to support this version?

Many thanks!

Sample manifest does not persist data

The sample manifest uses file storage in /var/vcap/jobs/vault, which is ephemeral storage. Additionally, the sample manifest deploys 3 instances. Targeting a different instance won't maintain data consistency.

post-start failed

This issue started with 1.0.0 bosh release. All was working on 0.8.0 release. The post-start job seems to be the same, did the vault binary itself change to cause the behavioral difference? The change is not necessarily a bad thing, but should be documented so the CSR can be generated properly.

vault-server/76005e04-f753-4c40-9bc7-d61808e8ea8c:/var/vcap/packages/vault/bin# ./vault unseal <key redacted>
WARNING! The "vault unseal" command is deprecated. Please use "vault operator
unseal" instead. This command will be removed in Vault 0.11 (or later).

Error unsealing: Put https://127.0.0.1:8200/v1/sys/unseal: x509: cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs

Thanks
Yansheng

Recommendation for health checks / discovering unsealed vaults

From the sample templates included here, I'm not sure how / whether you recommend setting up service discovery and health checks so that clients don't hit sealed vault instances. For example, the vault consul backend adds a vault service with active and standby tags, so that clients using consul dns can access active.vault.service.consul. Or clients can hit vault via a load balancer that uses the vault health check endpoint, as in https://github.com/hashicorp/vault/blob/master/terraform/aws/main.tf#L76-L107. This might be out of scope for this release, but I think adding recommendations for health checks of some kind would be useful. WDYT?

Discussion: Avoiding downtime due to seal on restart

Hi all,

New to Vault, still trying to wrap my head around it. As I understand it, Vault automatically seals itself on restart as it doesn't persist the unseal keys. While more secure, this seems like a rough match for the BOSH deployment process as bumping a stemcell results in Vault downtime until a human or multiple humans run vault unseal.

Any thoughts on adding automatic unsealing to this release to allow a more usual BOSH workflow or would that be sacrificing a valuable security feature? Related thread on Vault GH here: hashicorp/vault#72.

Prep Next Release

Time to release #51.

  • Write / Review Release Notes
  • Write / Review migration process in README
  • Fix CI
  • Bump Major Version
  • Announce in #vault channel

LDAP Auth Method

How can I enable and configure LDAP Auth Method to vault-boshrelease ?

post-start script pass but no changes, vault is sealed

/var/vcap/jobs/vault/data/unseal_keys
include 3 kays and one empty line

- azs:
  - AZ1
  - AZ1
  - AZ3
  instances: 3
  jobs:
  - name: consul
    release: consul
  - name: vault
    properties:
      tls:
      - cert: cert
      - key: key
        name: vault
      vault:
        config: |
          storage "consul" {
            path = "vault/"
            check_timeout = "5s"
            max_parallel = "128"
          }
          listener "tcp" {
            address = "0.0.0.0:8200"
            tls_cert_file = "/var/vcap/jobs/vault/tls/vault/cert.pem"
            tls_key_file  = "/var/vcap/jobs/vault/tls/vault/key.pem"
            tls_min_version = "tls12"
          }
          api_addr = "http://(ip):8200"
          cluster_addr = "https://(ip):8201"
        update:
          unseal_keys:
          - key1
          - key2
          - key3

deployment pass without failed but vault was not unseal

i try to run script by root

vault/f592421b-3aec-4cf1-915b-c6e19725e0c6:/var/vcap/jobs/vault/bin# ./post-start 
+ source /var/vcap/jobs/vault/helpers/ctl_setup.sh vault
++ set -e
++ set -u
++ JOB_NAME=vault
++ output_label=vault
++ export JOB_DIR=/var/vcap/jobs/vault
++ JOB_DIR=/var/vcap/jobs/vault
++ chmod 755 /var/vcap/jobs/vault
++ source /var/vcap/jobs/vault/data/properties.sh
+++ export NAME=vault
+++ NAME=vault
+++ export JOB_INDEX=2
+++ JOB_INDEX=2
+++ export JOB_FULL=vault/2
+++ JOB_FULL=vault/2
+++ export VAULT_ADDR=https://127.0.0.1:8200
+++ VAULT_ADDR=https://127.0.0.1:8200
+++ export VAULT_TOKEN=
+++ VAULT_TOKEN=
++ source /var/vcap/jobs/vault/helpers/ctl_utils.sh
++ redirect_output vault
++ SCRIPT=vault
++ mkdir -p /var/vcap/sys/log/monit
++ exec
++ exec
vault/f592421b-3aec-4cf1-915b-c6e19725e0c6:/var/vcap/jobs/vault/bin# 

Support Raw Configuration / Eliminate Backends

Introduce a new property, config that contains a big long string of HCL to inject into the config.

This will allow us to retire 80% of the properties in this BOSH release, while allowing tinkerers to tinker to their tinkering hearts' content. People who want a stable, curated Vault should look at the safe BOSH release (https://github.com/cloudfoundry-community/safe-boshrelease).

Once we have a release with the config support, that people can migrate via, we'll deprecate the old custom backend properties, bump major version and cut a new release.

Sample manifest doesn't include generated CA

To reproduce:

  1. Create a deployment with the sample manifest
    bosh -d vault deploy manifests/vault.yml --vars-store vars.yml
  2. Copy CA certificate from vars.yml to a pem file, and export VAULT_CACERT=<path_to_ca_file>
  3. Issue a vault command (e.g. vault status)
    Result: Error checking seal status: Get https://vault.pcip.cf:8200/v1/sys/seal-status: x509: certificate signed by unknown authority

The sample manifest has a variable vault-ca used to sign vault-tls, but vault-ca.certificate is not appended to vault-tls.certificate in vault's job properties properties.tls.cert

vault 0.6.0 is out

The new release of vault is out. Should be upgraded along with jumpbox to keep the vault versions syncrhonized

Vault HA configurations, how to use, and how it works?

i have 3 nodes with vault with s3 backend, with static ips:

vault/46ed57a5-e09d-4037-aaf3-783f4c291067 running az2 101.35.96.73
vault/6ef5fbf7-d4d7-438a-bdfd-b4d67453ab87 running az1 101.35.96.71 (master node)
vault/c382f314-9af1-4204-bb9c-91bac745eac0 running az3 101.35.96.72

but the client has only one record:
export VAULT_ADDR=https://vault-dev.net:8200
vault-dev.net - 101.35.96.71 (master node)
How to configure HA correctly?

e.g:
if vault/6ef5fbf7-d4d7-438a-bdfd-b4d67453ab87 running DC10P1 101.35.96.71
will down how it will works ?

If the master node goes down, there is no automatic failover/load balancing. Because the DNS is pointing at a specific node.

DynamoDB Unmarshal errors

Just noting here in case others run into this nasty issue caused by a bug in the aws-sdk: hashicorp/vault#4721

It's fixed in master right now but until 0.10.3 gets released it's probably best to downgrade back to the 1.0.0 bosh release.

Hide versioning information

Hi,

Is there a way to hide the vault's versioning information from all the possible "public" vault's places, like the versioning information in the UI (at the bottom there is a banner like ยฉ 2021 HashiCorp Vault 1.4.0 Upgrade to Vault Enterprise Documentation) or from the API endpoints /v1/sys/health and /v1/sys/seal-status which also return a "version" key.

Impact
The disclosure of version or system information allows an attacker to conduct a selective search in vulnerability databases. The obtained information can then be used as a basis for attacks.
Recommendation
It is recommended not to disclose any information about the system or available services. Such information should be removed from banners.

Thanks a lot,

vault post-start failed due to SSL check error

I am opening this as a separate issue from #58 .

The reason release 1.0.0 gets the ssl error (but was fine 0.8.3) is due to the code vault_addr=p("vault.address", "") now always returns "", and therefore VAULT_SKIP_VERIFY will not be set.

While this can be considered as bug since it breaks behavior from 0.8.3, I would argue the original feature was a bad idea of ignoring SSL check. So it can be handled multiple ways.

  • Update the readme requiring SAN IP be included in the cert (that works as I verified). This would be my recommendation.
  • Or update the file to be backward compatible. This can be cheated by requiring the config to include a dumb property like "address: https" to fool the script and having VAULT_SKIP_VERIFY to be set. The parameter would have no other purpose as well. The more you think about this, the more you feel it is a bad idea.

<% if vault_addr.include? "https" %>

vault unbind error question

Hi. We are using vault cluster with consul.
When we try to unbind the consul, it's failing with below messages. Can I know why and how can I debug?

2017/09/21 11:55:45 [unbind ea9e3158-eb34-4e72-9e52-6e8c7efaca1d / 8dde40c2-8dda-43fc-8def-3b2225017e1f] unbinding service
2017/09/21 11:55:45 [unbind ea9e3158-eb34-4e72-9e52-6e8c7efaca1d / 8dde40c2-8dda-43fc-8def-3b2225017e1f] using vault at https://SECRET
2017/09/21 11:55:45 [unbind ea9e3158-eb34-4e72-9e52-6e8c7efaca1d / 8dde40c2-8dda-43fc-8def-3b2225017e1f] retrieving access token
2017/09/21 11:55:45 [unbind ea9e3158-eb34-4e72-9e52-6e8c7efaca1d / 8dde40c2-8dda-43fc-8def-3b2225017e1f] revoking token '9SECRETb'
2017/09/21 11:55:45 [unbind ea9e3158-eb34-4e72-9e52-6e8c7efaca1d / 8dde40c2-8dda-43fc-8def-3b2225017e1f] error: vault returned a 200 OK

There is no error messages at vault and consul also.
CF api return message is
"error_details": {
"description": "Service instance vault-svc: Service broker error: Received 200 OK from Vault",
"error_code": "CF-ServiceBrokerBadResponse",
"code": 10001,
"http": {
"uri": "https://SECRET/v2/service_instances/ea9e31588-eb34-4e72-9e52-6e8c7efaca1d/service_bindings/8dde40c2-8dda-43fc-8def-3b2225017e1f",
"method": "DELETE",
"status": 500
}

  • Broker's Revoke return message seems like this
    {"request_id":"96acdd59-30d2-6f5e-8652-64ea70a0b5eb","lease_id":"","renewable":false,"lease_duration":0,"data":null,"wrap_info":null,"warnings":["Using a token in the path is unsafe as the token can be logged in many places. Please use POST or PUT with the token passed in via the "token" parameter."],"auth":null}

Support VAULT_ADVERTISE_ADDR

Add a new property to the vault job, vault.ha.name that defaults to vault-(index). The new property will be evaluated on a per-job basis, replacing the following:

  • (deployment) becomes the deployment name
  • (job) becomes the job name
  • (index) becomes the instance index

Set the VAULT_ADVERTISE_ADDR to the final value, for HA backends to use for redirection.

This will allow sites with HA configured to handle redirection after a change in leadership.

For example, in a 3-node Vault cluster with a vault.ha.name of vault-(index).example.com, users can access vault-0.example.com, and be transparently redirected to vault-2.example.com

Cut a new release please!

Could you cut a new release?
I would like to use the official release instead of my fork with google cloud support.. :)

Upgrade to Vault 0.9.0

While we're at it, drop the older blobs and remove the stupid glob in the package spec.

CI could automatically detect blobs

Hashicorp person gave me a JSON endpoint that returns list of available versions; so I think we could now create a hashicorp-release-resource and detect new releases:

$ curl -s https://releases.hashicorp.com/vault/index.json | jq -r '.versions[].builds[].url' | grep linux_amd64 | tail -n1
https://releases.hashicorp.com/vault/0.8.1/vault_0.8.1_linux_amd64.zip

Option to run vault as a linux user

Vault process is now invoked by root. However, administrator may need to execute vault as normal user when writing to NFS backend. It also increases security overall.

aws-ec2 template doesn't work

When this commit was added:

8b6213e

The templates/infrastructure-aws-ec2.yml file doesn't actually account for the backend at all (not even as a parameter), so now ./templates/make_manifest aws-ec2 just completely fails with:

1 error(s) detected:

  • $.jobs.vault.properties.vault.backend: Specify a backend for the vault to be stored in

instead of actually asking for the parameter.

Upgrade to vault 1.4.2

Hi there,

We're using this bosh release and would like to upgrade to the most recent version of vault. Is this project still maintained? I don't have any experience with bosh releases myself, so I am a bit lost with this.

Thanks a bunch!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.