Friday, June 21, 2019

SOLVED restore chef nodes, clients, vaults from knife-ec-backup


RESTORE A CHEF VAULT ITEM

A vault item is made of two data bags.

   Data bag 1 is: VAULTNAME
   Data bag 2 is:  VAULTNAME_KEYS.

Restore the data bags and you restore the vault item.

Restore  just (1) data bag and you break the entire vault so nobody else can use it until you restore the other data bag or delete your first data bag. The general process is:
  1. Make a copy of the chef backup 
  2.  cd to the directory corresponding to the organization and vault you want to restore
  3.  run the knife commands to restore the data bags
cd ~/backup_dir/organizations/your-org-dev/data_bags/certs/
knife data bag from file certs root_cert_wrtc_your-orgdev_com.json --config-file ~/.chef/knife.rb
knife data bag from file certs root_cert_wrtc_your-orgdev_com_keys.json --config-file ~/.chef/knife.rb

RESTORE A CHEF CLIENT


The general process is:
  1. Install the 'jq' JSON manipulation tool
  2. Make a copy of the chef backup 
  3. cd to the directory corresponding to the organization you want to restore a client to
  4. Extract the public key from the backup file
  5. Run the knife client command to create the client

sudo apt install jq
cd ~/backup_dir/organizations/your-org-dev/clients
jq .public_key .json > client-one.example.com.public_key
sed -i 's/\\n/\n/g' client-one.example.com.public_key
knife client create client-one.example.com --public-key client-one.example.com.public_key

NOTE: There is no obvious way to run 'knife client create' without it popping up an editor

RESTORE A CHEF NODE


The general process is:
  1. Make a copy of the chef backup 
  2. cd to the directory corresponding to the organization you want to restore a node to
  3. Run the knife node command to re-create the node
  cd ~/backup_dir/organizations/your-org-dev/nodes
  knife node from file EDV_omacneil_1558372161_AWS.fmr.com

No comments:

Post a Comment