- name: Install apache2 on Debian hosts: webservers become: yes tasks: - name: Update apt cache ansible.builtin.apt: update_cache: yes
- name: Install apache2
ansible.builtin.apt:
name: apache2
state: present
- name: Ensure apache2 is running
ansible.builtin.service:
name: apache2
state: started
enabled: yes
[webservers] managed_node ansible_host=192.168.100.101 ansible_user=star
#!/bin/bash
sudo apt update
sudo apt upgrade -y
sudo apt install fontconfig git default-jre -y
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]"
https://pkg.jenkins.io/debian-stable binary/ | sudo tee
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins -y
systemctl is-active jenkins
#MAIN.TF provider "aws" { region = var.region }
resource "aws_instance" "debian_ec2" { ami = var.ami_id instance_type = var.instance_type key_name = var.key_name associate_public_ip_address = true vpc_security_group_ids = [aws_security_group.allow_ssh.id]
tags = { Name = "Debian-Terraform-EC2" } }
resource "aws_security_group" "allow_ssh" { name = "allow_ssh" description = "Allow SSH inbound traffic"
ingress { from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] # Use your IP/CIDR for better security }
egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } }
#OUTPUT.TF
output "instance_ip" { value = aws_instance.debian_ec2.public_ip description = "The public IP address of the instance" }
output "instance_id" { value = aws_instance.debian_ec2.id description = "The ID of the instance" }
#VARIABLE.TF variable "region" { default = "us-east-1" }
variable "ami_id" { description = "Debian 12 AMI ID" default = "ami-0779caf41f9ba54f0" # Debian 12 (Bookworm) in us-east-1 }
variable "instance_type" { default = "t2.micro" }
variable "key_name" { description = "Enter a key pair" }
#!/bin/bash sudo apt install wget -y sudo apt-get update && sudo apt-get install -y wget gnupg software-properties-common
wget -O- https://apt.releases.hashicorp.com/gpg |
gpg --dearmor |
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
gpg --no-default-keyring
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg
--fingerprint
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg]
https://apt.releases.hashicorp.com $(lsb_release -cs) main" |
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt-get install terraform -y
sudo apt install -y awscli aws --version
Content type
Image
Digest
sha256:ea17bba38…
Size
48.2 MB
Last updated
over 1 year ago
docker pull r7vishwajit/flask-demo-app