This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
region = "${var.region}" | |
profile = "${var.profile}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_key_pair" "demo_key" { | |
key_name = "MyKeyPair" | |
public_key = "${file(var.public_key)}" | |
} | |
/* | |
resource "aws_vpc" "my-vpc" { | |
cidr_block = "10.0.0.0/16" # Defines overall VPC address space | |
enable_dns_hostnames = true # Enable DNS hostnames for this VPC | |
enable_dns_support = true # Enable DNS resolving support for this VPC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output "url-jenkins" { | |
value = "http://${aws_instance.jenkins-ci.0.public_ip}:8080" | |
} | |
output "url-gitLab" { | |
value = "http://${aws_instance.gitLab.0.public_ip}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_version = ">= 0.11.11" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "profile" { | |
default = "terraform_iam_user" | |
} | |
variable "region" { | |
default = "ap-southeast-1" | |
} | |
variable "instance" { | |
default = "t2.nano" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Install Oracle Java version 8 | |
hosts: java | |
become: true | |
tasks: | |
- name: Install dependencies | |
become: yes | |
apt: | |
name: "{{ packages }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Install Jenkins | |
hosts: jenkins-ci | |
gather_facts: false | |
become: true | |
tasks: | |
- name: Ensure the jenkins apt repository key is installed | |
apt_key: | |
url: https://pkg.jenkins.io/debian-stable/jenkins.io.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Install GitLab | |
hosts: gitLab | |
become: true | |
tasks: | |
- name: Checking to make sure postfix is installed | |
apt: | |
name: | |
- postfix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ansible requires Python to be installed on the remote machine as well as the local machine. | |
provisioner "remote-exec" { | |
inline = ["sudo apt-get -qq install python -y"] | |
} | |
connection { | |
private_key = "${file(var.private_key)}" | |
user = "ubuntu" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is where we configure the instance with ansible-playbook | |
# Jenkins requires Java to be installed | |
provisioner "local-exec" { | |
command = <<EOT | |
sleep 30; | |
>java.ini; | |
echo "[java]" | tee -a java.ini; | |
echo "${aws_instance.jenkins-ci.public_ip} ansible_user=${var.ansible_user} ansible_ssh_private_key_file=${var.private_key}" | tee -a java.ini; | |
export ANSIBLE_HOST_KEY_CHECKING=False; | |
ansible-playbook -u ${var.ansible_user} --private-key ${var.private_key} -i java.ini ../playbooks/install_java.yaml |
OlderNewer