mirror of
https://framagit.org/fiat-tux/hat-softwares/lutim.git
synced 2026-03-28 17:42:54 +01:00
Merge branch 'ansible-tarraform-provisioning' into 'development'
Adhere to ansible styling guide See merge request fiat-tux/hat-softwares/lutim!86
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
---
|
||||
language: python
|
||||
python: "2.7"
|
||||
|
||||
# Use the new container infrastructure
|
||||
sudo: false
|
||||
|
||||
# Install ansible
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- python-pip
|
||||
|
||||
install:
|
||||
# Install ansible
|
||||
- pip install ansible
|
||||
|
||||
# Check ansible version
|
||||
- ansible --version
|
||||
|
||||
# Create ansible.cfg with correct roles_path
|
||||
- printf '[defaults]\nroles_path=../' >ansible.cfg
|
||||
|
||||
script:
|
||||
# Basic role syntax check
|
||||
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
@@ -9,10 +9,10 @@ Role Variables
|
||||
| `app_dir` | /var/www/lutim | Set the application directory for the best practice |
|
||||
| `lutim_owner` | www-data | Set the application user for the best practice |
|
||||
| `lutim_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. |
|
||||
| `secrets` | ffyg7kbkjba | Secrets option (mandotory), which is array of random string. Used by Mojolicious for encrypting session cookies |
|
||||
| `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. |
|
||||
| `_secrets` | ffyg7kbkjba | Secrets option (mandotory), which is array of random string. Used by Mojolicious for encrypting session cookies |
|
||||
| `_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
|
||||
--------------
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
---
|
||||
# defaults file for ansible-role-lutim
|
||||
@@ -1,52 +0,0 @@
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
# platforms:
|
||||
# - name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 25
|
||||
# - name: SomePlatform
|
||||
# versions:
|
||||
# - all
|
||||
# - 1.0
|
||||
# - 7
|
||||
# - 99.99
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
@@ -6,7 +6,7 @@
|
||||
chdir: "{{ app_dir }}"
|
||||
|
||||
- name: Upload application config file
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: ../templates/lutim.conf.j2
|
||||
dest: "{{ app_dir }}/lutim.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,10 +1,10 @@
|
||||
# dependencies.yaml
|
||||
---
|
||||
- name: Lutim | Update apt cache
|
||||
apt: update_cache=yes
|
||||
ansible.builtin.apt: update_cache=yes
|
||||
changed_when: no
|
||||
- name: Install Dependencies
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- nginx
|
||||
- carton
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
server {
|
||||
listen 80;
|
||||
# No need to have a `root` parameter.
|
||||
server_name {{ servername }};
|
||||
server_name {{ _server_name }};
|
||||
# This is important for user's privacy !
|
||||
access_log off;
|
||||
error_log /var/log/nginx/lutim.error.log;
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
# put a way to contact you here and uncomment it
|
||||
# mandatory
|
||||
contact => '{{ contact }}',
|
||||
contact => '{{ _contact }}',
|
||||
|
||||
# random string used to encrypt cookies
|
||||
# mandatory
|
||||
secrets => ['{{ secrets }}'],
|
||||
secrets => ['{{ _secrets }}'],
|
||||
|
||||
# choose a theme. See the available themes in `themes` directory
|
||||
# optional, default is 'default'
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- ansible-role-lutim
|
||||
@@ -5,12 +5,12 @@ lutim_owner: "www-data"
|
||||
|
||||
lutim_group: "www-data"
|
||||
|
||||
contact: "contact.example.com"
|
||||
|
||||
app_dir: "/var/www/lutim"
|
||||
|
||||
secrets: "yyiqwhuqwg"
|
||||
_contact: ""
|
||||
|
||||
project_version: "master"
|
||||
_secrets: ""
|
||||
|
||||
servername: "192.168.56.18"
|
||||
_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" = "lutim-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 = {
|
||||
@@ -31,7 +31,7 @@ resource "aws_subnet" "publicsubnet" {
|
||||
|
||||
# Create routeTable
|
||||
resource "aws_route_table" "publicroute" {
|
||||
vpc_id = "${aws_vpc.MAIN.id}"
|
||||
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}"
|
||||
vpc_id = "${aws_vpc.vpc.id}"
|
||||
route_table_id = "${aws_route_table.publicroute.id}"
|
||||
}
|
||||
## Create security group
|
||||
resource "aws_security_group" "security" {
|
||||
name = "lutim-master-sg"
|
||||
description = "allow all traffic"
|
||||
vpc_id = "${aws_vpc.MAIN.id}"
|
||||
vpc_id = "${aws_vpc.vpc.id}"
|
||||
|
||||
ingress {
|
||||
description = "allow all traffic"
|
||||
@@ -75,6 +75,17 @@ resource "aws_security_group" "security" {
|
||||
|
||||
}
|
||||
|
||||
# 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-*"]
|
||||
}
|
||||
}
|
||||
|
||||
#Create key_pair for the instance
|
||||
|
||||
resource "aws_key_pair" "genkey" {
|
||||
@@ -84,7 +95,7 @@ resource "aws_key_pair" "genkey" {
|
||||
|
||||
# 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}"
|
||||
|
||||
Reference in New Issue
Block a user