Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nishant-jain-94/terraform-gitlab-organization

A Terraform Module to Provision Gitlab Resources on Gitlab Instance
https://github.com/nishant-jain-94/terraform-gitlab-organization

gitlab terraform terraform-gitlab terraform-module

Last synced: 5 days ago
JSON representation

A Terraform Module to Provision Gitlab Resources on Gitlab Instance

Awesome Lists containing this project

README

        

# terraform-gitlab-organization ![](https://github.com/nishant-jain-94/terraform-gitlab-organization/workflows/terraform_testing/badge.svg)

A Terraform Module to Provision Gitlab Resources on Gitlab Instance

## :rocket: Features

- [Add Users](#add-users)
- [Add Groups](#add-groups)
- [Add Users to Groups](#add-users-to-groups)
- [Add Projects to Groups](#add-projects-to-groups)

## :information_desk_person: Usage

### Add Users

Add Users Details

#### main.tf
```terraform
variable "gitlab_token" {
type = "string"
}

variable "base_url" {
type = "string"
}

variable "users" {
default = {}
}

module "add_users" {
source = "../../"
gitlab_token = var.gitlab_token
base_url = var.base_url
users = var.users
}
```

#### users.auto.tfvars.json

```json
{
"users": {
"[email protected]": {
"username": "aditya.singh",
"email": "[email protected]",
"password": "password@123",
"groups_access": {},
"projects_access": {}
},
"[email protected]": {
"username": "raj.singh",
"email": "[email protected]",
"password": "password@123",
"groups_access": {},
"projects_access": {}
}
}
}
```

### Add Groups

Add Groups

#### main.tf

```terraform
variable "gitlab_token" {
type = "string"
}

variable "base_url" {
type = "string"
}

variable groups {
default = {}
}

module "add_groups" {
source = "../../"
gitlab_token = var.gitlab_token
base_url = var.base_url
groups = var.groups
}
```

#### groups.auto.tfvars.json
```json
{
"groups": {
"northwind-wave-2": {
"group_name": "northwind-wave-2",
"group_description": "A Group for entire northwind Wave 1"
},
"northwind-mentors-1": {
"group_name": "northwind-mentors-1",
"group_description": "Group Created for northwind mentors"
},
"northwind-auditors-1": {
"group_name": "northwind-auditors-1",
"group_description": "Group Created for auditors"
}
}
}
```

### Add Users to Groups

Add Users to Groups

#### main.tf
```terraform
variable "gitlab_token" {
type = "string"
}

variable "base_url" {
type = "string"
}

variable "users" {
default = {}
}

variable "groups" {
default = {}
}

variable "user_namespaces" {
default = {}
}

variable "group_namespaces" {
default = {}
}

module "add_groups_users" {
source = "../../"
gitlab_token = var.gitlab_token
base_url = var.base_url
groups = var.groups
users = var.users
user_namespaces = var.user_namespaces
group_namespaces = var.group_namespaces
}
```

#### groups.auto.tfvars.json
```json
{
"groups": {
"northwind-wave-2": {
"group_name": "northwind-wave-2",
"group_description": "A Group for entire northwind Wave 1"
},
"northwind-mentors-1": {
"group_name": "northwind-mentors-1",
"group_description": "Group Created for northwind mentors"
},
"northwind-auditors-1": {
"group_name": "northwind-auditors-1",
"group_description": "Group Created for auditors"
}
}
}
```

#### users.auto.tfvars.json
```json
{
"users": {
"[email protected]": {
"username": "aditya.singh",
"email": "[email protected]",
"password": "password@123",
"groups_access": {},
"projects_access": {}
},
"[email protected]": {
"username": "raj.singh",
"email": "[email protected]",
"password": "password@123",
"groups_access": {},
"projects_access": {}
}
}
}
```

#### namespaces.auto.tfvars.json

```json
{
"group_namespaces": {
"northwind-wave-2": {
"group_name": "northwind-wave-2"
},
"northwind-mentors-1": {
"group_name": "northwind-mentors-1"
},
"northwind-auditors-1": {
"group_name": "northwind-auditors-1"
}
},
"user_namespaces": {
"aditya.singh": {
"email": "[email protected]"
},
"raj.singh": {
"email": "[email protected]"
},
"harry.potter": {
"email": "[email protected]"
},
"alice.wonderland": {
"email": "[email protected]"
}
}
}
```

### Add Projects to Groups

Add Projects to Groups

#### main.tf

```terraform
variable "gitlab_token" {
type = "string"
}

variable "base_url" {
type = "string"
}

variable "users" {
default = {}
}

variable "projects" {
default = {}
}

variable "groups" {
default = {}
}

variable "user_namespaces" {
default = {}
}

variable "group_namespaces" {
default = {}
}

module "add_users_projects" {
source = "../../"
gitlab_token = var.gitlab_token
base_url = var.base_url
projects = var.projects
groups = var.groups
user_namespaces = var.user_namespaces
group_namespaces = var.group_namespaces
}
```

#### groups.auto.tfvars.json

```json
{
"groups": {
"northwind-wave-2": {
"group_name": "northwind-wave-2",
"group_description": "A Group for entire northwind Wave 1"
},
"northwind-mentors-1": {
"group_name": "northwind-mentors-1",
"group_description": "Group Created for northwind mentors"
},
"northwind-auditors-1": {
"group_name": "northwind-auditors-1",
"group_description": "Group Created for auditors"
}
}
}
```

#### namespaces.auto.tfvars.json
```json
{
"group_namespaces": {
"northwind-wave-2": {
"group_name":"northwind-wave-2"
},
"northwind-mentors-1": {
"group_name": "northwind-mentors-1"
},
"northwind-auditors-1": {
"group_name": "northwind-auditors-1"
}
},
"user_namespaces": {}
}
```

#### projects.auto.tfvars.json
```json
{
"projects": {
"mentors-project-1": {
"name": "mentors-project-1",
"description": "This is only the Test Project",
"visibility_level": "private",
"namespace_id": "northwind-mentors-1",
"only_allow_merge_if_pipeline_succeeds": false,
"shared_with_groups": {}
},
"users-project-1": {
"name": "users-project-1",
"description": "This is only the Test Project",
"visibility_level": "private",
"namespace_id": "northwind-auditors-1",
"only_allow_merge_if_pipeline_succeeds": true,
"shared_with_groups": {
"northwind-wave-2": "guest"
}
}
}
}
```

## :pencil: Contribution Guidelines

Contributions to this Module are very much welcome. Checkout the [Contribution Guidelines](./CONTRIBUTING.md) for instructions.

## :bookmark: Changelog

Changelog to this terraform module are logged here on [Changelog](./CHANGELOG.md).

## :bug: Issues

Incase of Issues or Feature requests log it here in the [issues](https://github.com/nishant-jain-94/terraform-gitlab-organization/issues) section.

## :page_facing_up: License
This code is release under MIT License. Please see [LICENSE](./LICENSE) for more details.