Skip to content

Commit

Permalink
feat: add terraform modules for all charms
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 authored and NucciTheBoss committed Jan 22, 2025
1 parent 5622152 commit 8a50471
Show file tree
Hide file tree
Showing 21 changed files with 740 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ external
.pytest_cache
requirements.txt
dev-requirements.txt

# Managed by Terraform

.terraform
.terraform.lock.hcl
*.tfstate*
50 changes: 50 additions & 0 deletions charms/cephfs-server-proxy/terraform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Terraform module for cephfs-server-proxy

This is a Terraform module facilitating the deployment of the cephfs-server-proxy charm using
the [Juju Terraform provider](https://github.com/juju/terraform-provider-juju).
For more information, refer to the
[documentation](https://registry.terraform.io/providers/juju/juju/latest/docs)
for the Juju Terraform provider.

## Requirements

This module requires a Juju model to be available. Refer to the [usage](#usage)
section for more details.

## API

### Inputs

This module offers the following configurable units:

| Name | Type | Description | Default | Required |
|---------------|-------------|----------------------------------------------------------|---------------------|:--------:|
| `app_name` | string | Application name | cephfs-server-proxy | |
| `base` | string | Base version to use for deployed machine | [email protected] | |
| `channel` | string | Channel that charm is deployed from | latest/edge | |
| `config` | map(string) | Map of charm configuration options to pass at deployment | {} | |
| `constraints` | string | Constraints for the charm deployment | "arch=amd64" | |
| `model_name` | string | Name of the model to deploy the charm to | | Y |
| `revision` | number | Revision number of charm to deploy | null | |
| `units` | number | Number of units to deploy | 1 | |

### Outputs

After applying, the module exports the following outputs:

| Name | Description |
|------------|-----------------------------|
| `app_name` | Application name |
| `provides` | Map of `provides` endpoints |

## Usage

Users should ensure that Terraform is aware of the Juju model dependency of the
charm module.

To deploy this module with its required dependency, you can run
the following command:

```shell
terraform apply -var="model_name=<MODEL_NAME>" -auto-approve
```
29 changes: 29 additions & 0 deletions charms/cephfs-server-proxy/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2025 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

resource "juju_application" "cephfs-server-proxy" {
name = var.app_name
model = var.model_name

charm {
name = "cephfs-server-proxy"
base = var.base
channel = var.channel
revision = var.revision
}

config = var.config
constraints = var.constraints
units = var.units
}
23 changes: 23 additions & 0 deletions charms/cephfs-server-proxy/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2025 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

output "app_name" {
value = juju_application.cephfs-server-proxy.name
}

output "provides" {
value = {
filesystem = "filesystem"
}
}
61 changes: 61 additions & 0 deletions charms/cephfs-server-proxy/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2025 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

variable "app_name" {
description = "Application name"
type = string
default = "cephfs-server-proxy"
}

variable "base" {
description = "Charm base"
type = string
default = "[email protected]"
}

variable "channel" {
description = "Charm channel"
type = string
default = "latest/edge"
}

variable "config" {
description = "Charm configuration"
type = map(string)
default = {}
}

variable "constraints" {
description = "Deployment constraints"
type = string
default = "arch=amd64"
}

variable "model_name" {
description = "Model name"
type = string
}

variable "revision" {
description = "Charm revision"
type = number
nullable = true
default = null
}

variable "units" {
description = "Number of units"
type = number
default = 1
}
22 changes: 22 additions & 0 deletions charms/cephfs-server-proxy/terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2025 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

terraform {
required_providers {
juju = {
source = "juju/juju"
version = ">= 0.14.0"
}
}
}
49 changes: 49 additions & 0 deletions charms/filesystem-client/terraform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Terraform module for filesystem-client

This is a Terraform module facilitating the deployment of the filesystem-client charm using
the [Juju Terraform provider](https://github.com/juju/terraform-provider-juju).
For more information, refer to the
[documentation](https://registry.terraform.io/providers/juju/juju/latest/docs)
for the Juju Terraform provider.

## Requirements

This module requires a Juju model to be available. Refer to the [usage](#usage)
section for more details.

## API

### Inputs

This module offers the following configurable units:

| Name | Type | Description | Default | Required |
|---------------|-------------|----------------------------------------------------------|-------------------|:--------:|
| `app_name` | string | Application name | filesystem-client | |
| `base` | string | Base version to use for deployed machine | [email protected] | |
| `channel` | string | Channel that charm is deployed from | latest/edge | |
| `config` | map(string) | Map of charm configuration options to pass at deployment | {} | |
| `constraints` | string | Constraints for the charm deployment | "arch=amd64" | |
| `model_name` | string | Name of the model to deploy the charm to | | Y |
| `revision` | number | Revision number of charm to deploy | null | |

### Outputs

After applying, the module exports the following outputs:

| Name | Description |
|------------|-----------------------------|
| `app_name` | Application name |
| `requires` | Map of `requires` endpoints |

## Usage

Users should ensure that Terraform is aware of the Juju model dependency of the
charm module.

To deploy this module with its required dependency, you can run
the following command:

```shell
terraform apply -var="model_name=<MODEL_NAME>" -auto-approve
```
29 changes: 29 additions & 0 deletions charms/filesystem-client/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2025 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

resource "juju_application" "filesystem-client" {
name = var.app_name
model = var.model_name

charm {
name = "filesystem-client"
base = var.base
channel = var.channel
revision = var.revision
}

config = var.config
constraints = var.constraints
units = 0
}
24 changes: 24 additions & 0 deletions charms/filesystem-client/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2025 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

output "app_name" {
value = juju_application.filesystem-client.name
}

output "requires" {
value = {
filesystem = "filesystem"
juju-info = "juju-info"
}
}
55 changes: 55 additions & 0 deletions charms/filesystem-client/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2025 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

variable "app_name" {
description = "Application name"
type = string
default = "filesystem-client"
}

variable "base" {
description = "Charm base"
type = string
default = "[email protected]"
}

variable "channel" {
description = "Charm channel"
type = string
default = "latest/edge"
}

variable "config" {
description = "Charm configuration"
type = map(string)
default = {}
}

variable "constraints" {
description = "Deployment constraints"
type = string
default = "arch=amd64"
}

variable "model_name" {
description = "Model name"
type = string
}

variable "revision" {
description = "Charm revision"
type = number
nullable = true
default = null
}
22 changes: 22 additions & 0 deletions charms/filesystem-client/terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2025 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

terraform {
required_providers {
juju = {
source = "juju/juju"
version = ">= 0.14.0"
}
}
}
Loading

0 comments on commit 8a50471

Please sign in to comment.