You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Pitchfork Layout (PFL) is a convention for arranging source, build, and resource files in a file system to support uniformity, comprehensibility, and partitioning.
1.1.1. Library
Layout and Structure
NOTE Replace <...> brackets with the library-specific information.
NOTE Replace <...> brackets with the module-specific information.
Files and Folders
1.3.2. Application
Layout and Structure
NOTE Replace <...> brackets with the application-specific information.
Files and Folders
/module
/docs
Package reference documentation.
/tests
Package unit tests, execution tests, integration tests.
/bin
Holds executable files.
setup.py
Package and distribution management.
requirements.txt
Package dependency and version management.
1.4. Ansible
1.4.1. Collection
An Ansible Collection packages and distributes roles, modules and plugins. Organizing Ansible Collection content under a directory structure, it is crucial to follow a specific layout to ensure that Ansible can recognize and properly utilize the collection.
Layout and Structure
The project path is based on the collections/ansible_collections keywords and the Fully Qualified Collection Name (FQCN) <namespace>.<collection>, in accordance with the naming convention.
NOTE None of the directories are required.
NOTE Replace <...> brackets with the project-specific information.
The source of the metadata file used to generate a collection on Galaxy and to build a collection artifact.
Modules
/meta
runtime.yml
plugins/
The Collections plugins directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that is named after the type of plugin it is in. It can also include the module_utils and modules directory that would contain module utils and modules respectively.
/modules
At least one plugin required.
__init__.py
A required empty file to initialize namespace and allow Python to import the files.
/inventory
At least one plugin required.
Roles
Playbooks
/docs
Describes the use of the roles, plugins and role requirements provided by the collection.
1.4.2. Playbook
Ansible Playbook directory layout organizes tasks in roles, with a inventory file for each environment and a playbooks.
Layout and Structure
NOTE Replace <...> brackets with the project-specific information.
Terraform modules define self-contained, reusable resources of Infrastructure-as-Code (IaC). The Terraform module structure for reusable modules distributed in separate repositories.
Layout and Structure
NOTE Replace <...> brackets with the module-specific information.
The Terraform project sets up a basic AWS infrastructure. This includes a VPC with public and private subnets and an EC2 instance on the public subnet.
main.tf
The root main.tf file contains the primary Terraform configuration and calls the modules.
Defines all the input variables for the root module.
variable"vpc_cidr" {
description="The CIDR block for the VPC"type=stringdefault="10.0.0.0/16"
}
variable"aws_region" {
description="The AWS region to deploy resources"type=stringdefault="us-east-1"
}
variable"instance_type" {
description="Type of the EC2 instance"type=string
}
outputs.tf
Specifies the outputs from the root module.
output"vpc_id" {
description="The ID of the VPC"value=module.network.vpc_id
}
output"public_subnet_id" {
description="The ID of the public subnet"value=module.network.public_subnet_id
}
output"instance_public_ip" {
description="The public IP of the EC2 instance"value=module.compute.instance_public_ip
}
providers.tf
Configures the providers used in the project.
provider"aws" {
region=var.aws_region
}
versions.tf
Sets the required Terraform and provider versions.
variable"vpc_cidr" {
description="CIDR block for the VPC"type=string
}
modules/network/outputs.tf
Defines outputs from the network module.
output"vpc_id" {
description="The ID of the VPC"value=aws_vpc.this.id
}
output"public_subnet_id" {
description="The ID of the public subnet"value=aws_subnet.public.id
}
variable"subnet_id" {
description="The ID of the subnet to deploy the instance"type=string
}
variable"instance_type" {
description="Type of the EC2 instance"type=string
}
modules/compute/outputs.tf
Defines outputs from the compute module.
output"instance_id" {
description="The ID of the EC2 instance"value=aws_instance.web.id
}
output"instance_public_ip" {
description="The public IP address of the EC2 instance"value=aws_instance.web.public_ip
}
environments/dev/main.tf
References the root module with development-specific variables.
Provides variable values specific to the dev environment.
NOTE Avoid including sensitive data, use environment variables or a secret management tool to handle sensitive data.
variable"vpc_cidr" {
description="The CIDR block for the VPC."type=stringdefault="10.1.0.0/16"
}
variable"aws_region" {
description="The AWS region where resources will be deployed."type=stringdefault="us-west-2"
}
variable"instance_type" {
description="The type to provide an EC2 instance resource."type=stringdefault="t2.micro"
}
Provides variable values specific to the prod environment.
NOTE Avoid including sensitive data, use environment variables or a secret management tool to handle sensitive data.
variable"vpc_cidr" {
description="The CIDR block for the VPC."type=stringdefault="10.2.0.0/16"
}
variable"aws_region" {
description="The AWS region where resources will be deployed."type=stringdefault="us-east-1"
}
variable"instance_type" {
description="The type to provide an EC2 instance resource."type=stringdefault="t3.large"
}
Project Layout Guide
1. Category
1.1. C/C++
The Pitchfork Layout (PFL) is a convention for arranging source, build, and resource files in a file system to support uniformity, comprehensibility, and partitioning.
1.1.1. Library
Layout and Structure
Files and Folders
1.1.2. Application
Layout and Structure
Files and Folders
1.2. Go
1.2.1. Package
Layout and Structure
Files and Folders
1.2.2. Application
Go Project Layout for applications. It is a set of common historical and emerging project layout patterns in the Go.
Layout and Structure
Files and Folders
/cmd
/internal
/pkg
/vendor
/configs
/init
/scripts
/build
/deployments
/test
/docs
/tools
/examples
/external
/githooks
/assets
/website
/api
/web
go.mod
go.sum
1.3. Python
Python Project Layout using best practices.
1.3.1. Module
Layout and Structure
Files and Folders
1.3.2. Application
Layout and Structure
Files and Folders
/module
/docs
/tests
/bin
setup.py
requirements.txt
1.4. Ansible
1.4.1. Collection
An Ansible Collection packages and distributes roles, modules and plugins. Organizing Ansible Collection content under a directory structure, it is crucial to follow a specific layout to ensure that Ansible can recognize and properly utilize the collection.
Layout and Structure
The project path is based on the
collections/ansible_collections
keywords and the Fully Qualified Collection Name (FQCN)<namespace>.<collection>
, in accordance with the naming convention.Files and Folders
galaxy.yml
Modules
/meta
runtime.yml
plugins/
/modules
__init__.py
/inventory
Roles
Playbooks
/docs
1.4.2. Playbook
Ansible Playbook directory layout organizes tasks in roles, with a inventory file for each environment and a playbooks.
Layout and Structure
Files and Folders
1.5. Terraform
1.5.1. Module
Terraform modules define self-contained, reusable resources of Infrastructure-as-Code (IaC). The Terraform module structure for reusable modules distributed in separate repositories.
Layout and Structure
Files and Folders
1.5.2. Project
Layout and Structure
Files and Folders
Examples and Explanations
The Terraform project sets up a basic AWS infrastructure. This includes a VPC with public and private subnets and an EC2 instance on the public subnet.
main.tf
variables.tf
outputs.tf
providers.tf
versions.tf
backend.tf
modules/network/main.tf
modules/network/variables.tf
modules/network/outputs.tf
modules/compute/main.tf
modules/compute/variables.tf
modules/compute/outputs.tf
environments/dev/main.tf
environments/dev/variables.tf
environments/dev/backend.tf
environments/prod/main.tf
environments/prod/variables.tf
environments/prod/backend.tf
2. References
The text was updated successfully, but these errors were encountered: