Skip to content

Commit

Permalink
tofu state to s3 (#354)
Browse files Browse the repository at this point in the history
* tofu state to s3

Bug: T352164

* maybe

* command line vars

* comments removed

* space
  • Loading branch information
vivian-rook authored Jan 9, 2024
1 parent 828256c commit bb371d6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ ansible/files/csi-secret-cinderplugin.yaml.codfw1dev.crypt filter=git-crypt diff
paws/codfw-secrets.yaml filter=git-crypt diff=git-crypt
paws/files/minesweeper/secrets/** filter=git-crypt diff=git-crypt
tofu/secrets.tf filter=git-crypt diff=git-crypt
secrets-eqiad1.sh filter=git-crypt diff=git-crypt
secrets-codfw1dev.sh filter=git-crypt diff=git-crypt
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,8 @@ bash deploy.sh <eqiad1|codfw1dev>
update the web proxy in horizon to point to current cluster.

https://wikitech.wikimedia.org/wiki/PAWS/Admin#Deployment

#### Disaster Recovery
If the entire project is removed two parts of paws are not managed by tofu/ansible.
Object storage container: An object storage container named "tofu-state" will need to be generated in horizon. This is where the state file for tofu resides.
NFS: The NFS server is not included. And a fresh NFS server will be needed for paws to operate.
20 changes: 18 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ else
exit
fi

if [ -n "${2}" ]
then
if [ "${2}" = 'tofu' ]
then
# exit after tofu
tofuonly=1
fi
fi


if ! command -v kubectl ; then
echo "please install kubectl"
Expand All @@ -31,15 +40,22 @@ if ! command -v tofu ; then
exit 1
fi

source secrets-${datacenter}.sh

python3 -m venv .venv/deploy
source .venv/deploy/bin/activate
pip install ansible==8.1.0 kubernetes==26.1.0


cd tofu
tofu init
tofu apply -var datacenter=${datacenter} # -auto-approve
AWS_ACCESS_KEY_ID=${ACCESS_KEY} AWS_SECRET_ACCESS_KEY=${SECRET_KEY} tofu init
AWS_ACCESS_KEY_ID=${ACCESS_KEY} AWS_SECRET_ACCESS_KEY=${SECRET_KEY} tofu apply -var datacenter=${datacenter} # -auto-approve
export KUBECONFIG=$(pwd)/kube.config

if [ "${tofuonly}" = '1' ]
then
exit
fi

cd ../ansible
ansible-playbook paws.yaml --extra-vars "datacenter=${datacenter}"
Binary file added secrets-eqiad1.sh
Binary file not shown.
10 changes: 10 additions & 0 deletions tofu/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
terraform {
required_version = ">= 1.6.0"
backend "s3" {
region = "eqiad1"
bucket = "paws:tofu-state"
endpoint = "https://object.eqiad1.wikimediacloud.org"
key = "state/main"

skip_region_validation = true
skip_credentials_validation = true
force_path_style = true
}
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
Expand Down

0 comments on commit bb371d6

Please sign in to comment.