Skip to content

Commit 22f95c4

Browse files
costimuraruConstantin Muraru
authored andcommitted
Add helmfile/terraform runner with hierarchical configuration support (#44)
* Add helmfile/terraform runner with hiera-like configuration support Signed-off-by: Constantin Muraru <[email protected]> * Fix tests Signed-off-by: Constantin Muraru <[email protected]> * Work1 * Integrate with existing terraform Signed-off-by: Constantin Muraru <[email protected]> * Rename ee to hierarchical * Minor tweaks * Update requirements.txt * Add example * Fix ansible warning * Fix build Signed-off-by: cmuraru <[email protected]> * Tweaks Signed-off-by: Constantin Muraru <[email protected]> * Tweaks * Fixes * Fixes * Fixes * Update readme * Downgrade aws-cli until it works in Spinnaker Signed-off-by: cmuraru <[email protected]> * Add epilog Signed-off-by: cmuraru <[email protected]> Signed-off-by: Constantin Muraru <[email protected]>
1 parent f67b11a commit 22f95c4

File tree

37 files changed

+1490
-468
lines changed

37 files changed

+1490
-468
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
ops.egg-info/
2+
*.plan
3+
*.tf.json
4+
*.tfvars.json
5+
*.tfstate
26
.cache/
37
*.pyc
48
.terraform

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ ops clusters/mycluster.yaml terraform --path-name aws-eks apply
5959

6060
![ops-terraform](https://user-images.githubusercontent.com/952836/52021396-9bc1b580-24fd-11e9-9da8-00fb68bd5c72.png)
6161

62+
## Run terraform by using hierarchical configs
63+
64+
See [examples/features/terraform-hierarchical](https://github.com/adobe/ops-cli/tree/master/examples/features/terraform-hierarchical)
65+
6266
## Create Kubernetes cluster (using AWS EKS)
6367

6468
See [examples/aws-kubernetes](https://github.com/adobe/ops-cli/tree/master/examples/aws-kubernetes)
@@ -85,8 +89,8 @@ pip2 install -U virtualenv
8589
virtualenv ops
8690
source ops/bin/activate
8791

88-
# install opswrapper v0.36 stable release
89-
pip2 install --upgrade https://github.com/adobe/ops-cli/releases/download/0.36/ops-0.36.tar.gz
92+
# install opswrapper v1.0 stable release
93+
pip2 install --upgrade https://github.com/adobe/ops-cli/releases/download/1.0/ops-1.0.tar.gz
9094

9195
# Optionally, install terraform to be able to access terraform plugin
9296
# See https://www.terraform.io/intro/getting-started/install.html
@@ -99,7 +103,7 @@ You can try out `ops-cli`, by using docker. The docker image has all required pr
99103

100104
To start out a container, running the latest `ops-cli` docker image run:
101105
```sh
102-
docker run -it adobe/ops-cli:0.36 bash
106+
docker run -it adobe/ops-cli:1.0 bash
103107
```
104108

105109
After the container has started, you can start using `ops-cli`:

build_scripts/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ RUN curl -sSL https://github.com/databus23/helm-diff/releases/download/v${HELM_D
7373

7474
USER root
7575
RUN HELM_HOME=/home/ops/.helm helm plugin install https://github.com/futuresimple/helm-secrets
76+
RUN HELM_HOME=/home/ops/.helm helm plugin install https://github.com/rimusz/helm-tiller
7677
RUN chown -R ops:ops /home/ops/.helm/plugins
7778

7879
COPY --from=compile-image /azure-cli /home/ops/.local/azure-cli

build_scripts/docker_push.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
set -e
33

44
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
5-
docker tag ops adobe/ops-cli:0.36
6-
docker push adobe/ops-cli:0.36
5+
docker tag ops adobe/ops-cli:1.0
6+
docker push adobe/ops-cli:1.0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
compositions_order:
3+
terraform:
4+
- account
5+
- network
6+
- cluster
7+
- spinnaker
8+
helmfile:
9+
- helmfiles
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
1. Run 'terraform plan' for all compositions for a given cluster:
2+
```sh
3+
# generates config and runs terraform
4+
ops config/env=dev/cluster=cluster1 terraform plan
5+
```
6+
7+
2. Run 'terraform apply' for all compositions for a given cluster:
8+
```sh
9+
ops config/env=dev/cluster=cluster1 terraform apply --skip-plan
10+
```
11+
12+
3. Run a single composition:
13+
```sh
14+
ops config/env=dev/cluster=cluster1/composition=network terraform apply --skip-plan
15+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "config" {}
2+
3+
module "cluster" {
4+
source = "../../../modules/cluster"
5+
config = var.config
6+
}
7+
8+
output "cluster_name" {
9+
value = var.config.cluster.name
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
variable "config" {}
2+
3+
module "network" {
4+
source = "../../../modules/network"
5+
config = var.config
6+
}

examples/features/terraform-hierarchical/config/env=dev/cluster=cluster1/composition=cluster/conf.yaml

Whitespace-only changes.

examples/features/terraform-hierarchical/config/env=dev/cluster=cluster1/composition=network/conf.yaml

Whitespace-only changes.

0 commit comments

Comments
 (0)