Applied ansible styling best practices and Terraform data sorces
This commit is contained in:
parent
3f1d8d822b
commit
17bcb2684f
|
@ -9,10 +9,10 @@ Role Variables
|
|||
| `app_dir` | /var/www/lufi | Set the application directory for the best practice |
|
||||
| `lufi_owner` | www-data | Set the application user for the best practice |
|
||||
| `lufi_group` | www-data | Set the application group for the best practice |
|
||||
| `contact` | contact.example.com | Contact option (mandatory), where you have to put some way for the users to contact you. |
|
||||
| `report` | report@example.com | report option (mandatory) Put an email address or an URL to let people report illegal files |
|
||||
| `project_version` | master | We can chose the project version either Master branch, Dev branch or tag based |
|
||||
| `servername` | IP address (or) CNAME/FQDN | Mention the Server Name for the Nginx configurations |
|
||||
| `_contact` | contact.example.com | Contact option (mandatory), where you have to put some way for the users to contact you. |
|
||||
| `_report` | report@example.com | report option (mandatory) Put an email address or an URL to let people report illegal files |
|
||||
| `_project_version` | master | We can chose the project version either Master branch, Dev branch or tag based |
|
||||
| `_server_name` | IP address (or) CNAME/FQDN | Mention the Server Name for the Nginx configurations |
|
||||
|
||||
Sample example of use in a playbook
|
||||
--------------
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
chdir: "{{ app_dir }}"
|
||||
|
||||
- name: Upload application file
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: ../templates/lufi.conf.j2
|
||||
dest: "{{ app_dir }}/lufi.conf"
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
|||
chdir: "{{ app_dir }}"
|
||||
|
||||
- name: Nginx configuration file add
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: ../templates/app.conf
|
||||
dest: /etc/nginx/conf.d/
|
||||
mode: '0644'
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#dependencies.yml
|
||||
---
|
||||
- name: Install Dependencies
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- nginx
|
||||
- build-essential
|
||||
|
@ -12,6 +14,6 @@
|
|||
state: present
|
||||
|
||||
- name: Install Postgress Dev Packages
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- libpq-dev
|
|
@ -21,12 +21,12 @@
|
|||
# Put a way to contact you here and uncomment it
|
||||
# You can put some HTML in it
|
||||
# MANDATORY
|
||||
contact => '<a href="https://{{ contact }}">Contact page</a>',
|
||||
contact => '<a href="https://{{ _contact }}">Contact page</a>',
|
||||
|
||||
# Put an URL or an email address to receive file reports and uncomment it
|
||||
# It's for make reporting illegal files easy for users
|
||||
# MANDATORY
|
||||
report => '{{ report }}',
|
||||
report => '{{ _report }}',
|
||||
|
||||
# Array of random strings used to encrypt cookies
|
||||
# optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT
|
||||
|
|
|
@ -5,12 +5,12 @@ lufi_owner: "www-data"
|
|||
|
||||
lufi_group: "www-data"
|
||||
|
||||
contact: "contact.example.com"
|
||||
|
||||
report: "report@example.com"
|
||||
|
||||
app_dir: ""
|
||||
|
||||
project_version: ""
|
||||
_contact: "contact.example.com"
|
||||
|
||||
servername: ""
|
||||
_report: "report@example.com"
|
||||
|
||||
_project_version: ""
|
||||
|
||||
_servername: ""
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#Create the VPC
|
||||
resource "aws_vpc" "MAIN" {
|
||||
resource "aws_vpc" "vpc" {
|
||||
cidr_block = "${var.vpc_cidr}"
|
||||
enable_dns_hostnames = true
|
||||
enable_dns_support = true
|
||||
|
@ -12,7 +12,7 @@ resource "aws_vpc" "MAIN" {
|
|||
# Create InternetGateWay and attach to VPC
|
||||
|
||||
resource "aws_internet_gateway" "IGW" {
|
||||
vpc_id = "${aws_vpc.MAIN.id}"
|
||||
vpc_id = "${aws_vpc.vpc.id}"
|
||||
tags = {
|
||||
"Name" = "lufi-master-igw"
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ resource "aws_internet_gateway" "IGW" {
|
|||
# Create a public subnet
|
||||
|
||||
resource "aws_subnet" "publicsubnet" {
|
||||
vpc_id = "${aws_vpc.MAIN.id}"
|
||||
vpc_id = "${aws_vpc.vpc.id}"
|
||||
cidr_block = "${var.public_subnet_cidr}"
|
||||
map_public_ip_on_launch = true
|
||||
tags = {
|
||||
|
@ -30,8 +30,8 @@ resource "aws_subnet" "publicsubnet" {
|
|||
}
|
||||
|
||||
# Create routeTable
|
||||
resource "aws_route_table" "publicroute" {
|
||||
vpc_id = "${aws_vpc.MAIN.id}"
|
||||
resource "aws_route_table" "public" {
|
||||
vpc_id = "${aws_vpc.vpc.id}"
|
||||
route {
|
||||
cidr_block = "0.0.0.0/0"
|
||||
gateway_id = "${aws_internet_gateway.IGW.id}"
|
||||
|
@ -43,14 +43,14 @@ resource "aws_route_table" "publicroute" {
|
|||
}
|
||||
|
||||
resource "aws_main_route_table_association" "mainRTB" {
|
||||
vpc_id = "${aws_vpc.MAIN.id}"
|
||||
route_table_id = "${aws_route_table.publicroute.id}"
|
||||
vpc_id = "${aws_vpc.vpc.id}"
|
||||
route_table_id = "${aws_route_table.public.id}"
|
||||
}
|
||||
## Create security group
|
||||
resource "aws_security_group" "security" {
|
||||
name = "lufi-master-sg"
|
||||
description = "allow all traffic"
|
||||
vpc_id = "${aws_vpc.MAIN.id}"
|
||||
vpc_id = "${aws_vpc.vpc.id}"
|
||||
|
||||
ingress {
|
||||
description = "allow all traffic"
|
||||
|
@ -82,9 +82,20 @@ resource "aws_key_pair" "genkey" {
|
|||
public_key = "${file(var.public_key)}"
|
||||
}
|
||||
|
||||
# Add ubuntu AMI
|
||||
data "aws_ami" "ubuntu" {
|
||||
most_recent = true
|
||||
owners = ["099720109477"]
|
||||
|
||||
filter {
|
||||
name = "name"
|
||||
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
|
||||
}
|
||||
}
|
||||
|
||||
# Craete ec2 instance
|
||||
resource "aws_instance" "ec2_instance" {
|
||||
ami = "ami-04505e74c0741db8d"
|
||||
ami = "${data.aws_ami.ubuntu.id}"
|
||||
instance_type = "t2.medium"
|
||||
associate_public_ip_address = "true"
|
||||
subnet_id = "${aws_subnet.publicsubnet.id}"
|
||||
|
|
Loading…
Reference in New Issue