This repository contains the OpenTofu configuration for managing the CCI-MOC GitHub organization.
.
├── archived-repositories
├── modules
│ └── common_repository
├── policy
├── scripts
└── team-members
7 directories
- The top level directory is the root of the active OpenTofu configuration.
- The
archived-repositoriesdirectory contains a separate OpenTofu configuration that manages older, archived CCI-MOC repositories. If any repository in this directory needs to be un-archived, part of that process should be bringing the repository configuration into the top level directory. - The
modulesdirectory contains OpenTofu modules referenced by our configuration. - The
team-membersdirectory contains team membership information, one CSV file for each team. - The
policydirectory contains Open Policy Agent policy definitions that are used to validate the complete configuration.scripts/check-policy.shrenders the OpenTofu plan as JSON and feeds this toconftest.
This repository includes the following OpenTofu modules:
The common_repository module is used to manage all repositories. It provides a consistent mechanism for creating the repository, applying a common set of labels, setting up user and team collaborators, creating branch protection rules, and managing other per-repository configuration.
Repository configurations live in `repositories.tf'. The simplest repository configuration will look like this:
module "repo-virtualbmc" {
source = "./modules/common_repository"
name = "virtualbmc"
description = "Virtual BMC for Ironic nodes using the IPMI protocol"
}This creates a repository with the default set of labels and no explicit collaborators. A repository with team collaborators and typical branch protection rules will look like this:
module "repo-moc-keycloak" {
source = "./modules/common_repository"
name = "moc-keycloak"
description = "Keycloak configuration for sso.massopen.cloud"
teams = {
"keycloak-workers" = "maintain"
"open-accelerator" = "push"
}
branch_protection = {
required_reviews = 2
required_status_checks = [
"pre-commit",
"bootstrap"
]
require_linear_history = true
}
}To create team, add a new entry to teams.csv. Each line consists of four fields:
name,description,privacy,parentnameis the team name. Life is easier if this is all lower case and contains no whitespace.descriptionis arbitrary text describing the team.privacysets the [team visibility]. This can beclosedorsecret. Aclosedteam can be seen and mentioned by any member of the organization, while asecretteam is only visible to team members and organization owners.parentis used to set a parent team
Team membership is managed in team-members/<team_name>.csv. Each file in this directory has two fields:
username,roleWhere username is the member name, and role is either member or maintainer. Note that an organization owner must always have maintainer membership in teams (otherwise there will be noise every time we run tofu plan because GitHub will report membership as maintainer and tofu will attempt to change it to member).