Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tofu state to s3 #354

Merged
merged 5 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading