diff --git a/.provision/ansible-role-lutim/.travis.yml b/.provision/ansible-role-lutim/.travis.yml deleted file mode 100644 index 36bbf62..0000000 --- a/.provision/ansible-role-lutim/.travis.yml +++ /dev/null @@ -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/ \ No newline at end of file diff --git a/.provision/ansible-role-lutim/README.md b/.provision/ansible-role-lutim/README.md index c368917..9c322bd 100644 --- a/.provision/ansible-role-lutim/README.md +++ b/.provision/ansible-role-lutim/README.md @@ -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 -------------- diff --git a/.provision/ansible-role-lutim/defaults/main.yml b/.provision/ansible-role-lutim/defaults/main.yml deleted file mode 100644 index f3a7ae3..0000000 --- a/.provision/ansible-role-lutim/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# defaults file for ansible-role-lutim diff --git a/.provision/ansible-role-lutim/meta/main.yml b/.provision/ansible-role-lutim/meta/main.yml deleted file mode 100644 index c572acc..0000000 --- a/.provision/ansible-role-lutim/meta/main.yml +++ /dev/null @@ -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. diff --git a/.provision/ansible-role-lutim/tasks/apprun.yaml b/.provision/ansible-role-lutim/tasks/apprun.yaml index def1aac..80891c7 100644 --- a/.provision/ansible-role-lutim/tasks/apprun.yaml +++ b/.provision/ansible-role-lutim/tasks/apprun.yaml @@ -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' diff --git a/.provision/ansible-role-lutim/tasks/dependencies.yaml b/.provision/ansible-role-lutim/tasks/dependencies.yaml index a240df6..e0199ea 100644 --- a/.provision/ansible-role-lutim/tasks/dependencies.yaml +++ b/.provision/ansible-role-lutim/tasks/dependencies.yaml @@ -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 diff --git a/.provision/ansible-role-lutim/templates/app.conf b/.provision/ansible-role-lutim/templates/app.conf index 78f1910..3e691a5 100644 --- a/.provision/ansible-role-lutim/templates/app.conf +++ b/.provision/ansible-role-lutim/templates/app.conf @@ -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; diff --git a/.provision/ansible-role-lutim/templates/lutim.conf.j2 b/.provision/ansible-role-lutim/templates/lutim.conf.j2 index f901cd7..568869c 100644 --- a/.provision/ansible-role-lutim/templates/lutim.conf.j2 +++ b/.provision/ansible-role-lutim/templates/lutim.conf.j2 @@ -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' diff --git a/.provision/ansible-role-lutim/tests/inventory b/.provision/ansible-role-lutim/tests/inventory deleted file mode 100644 index 878877b..0000000 --- a/.provision/ansible-role-lutim/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost - diff --git a/.provision/ansible-role-lutim/tests/test.yml b/.provision/ansible-role-lutim/tests/test.yml deleted file mode 100644 index 9069ed2..0000000 --- a/.provision/ansible-role-lutim/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - ansible-role-lutim diff --git a/.provision/ansible-role-lutim/vars/main.yml b/.provision/ansible-role-lutim/vars/main.yml index 5dc5011..2e28a1c 100644 --- a/.provision/ansible-role-lutim/vars/main.yml +++ b/.provision/ansible-role-lutim/vars/main.yml @@ -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" \ No newline at end of file +_project_version: "" + +_servername: "" \ No newline at end of file diff --git a/.provision/terraform-aws-lutim/main.tf b/.provision/terraform-aws-lutim/main.tf index f209728..8f42a01 100644 --- a/.provision/terraform-aws-lutim/main.tf +++ b/.provision/terraform-aws-lutim/main.tf @@ -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}"