mirror of
https://github.com/JamesTurland/JimsGarage.git
synced 2024-11-24 17:00:22 +00:00
ansible-copy
This commit is contained in:
parent
cac5d0df8a
commit
8623f316a6
6 changed files with 223 additions and 0 deletions
52
Ansible/Playbooks/File-Copy/File-Copy-Playbook.yaml
Normal file
52
Ansible/Playbooks/File-Copy/File-Copy-Playbook.yaml
Normal file
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
- name: Deploy Docker Container with Docker Compose
|
||||
hosts: all
|
||||
become: true
|
||||
tasks:
|
||||
- name: Ensure Docker is installed
|
||||
ansible.builtin.package:
|
||||
name: docker
|
||||
state: present
|
||||
|
||||
- name: Ensure Docker service is running
|
||||
ansible.builtin.service:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Create a directory for Docker Compose files
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/ansible-docker/docker-compose
|
||||
state: directory
|
||||
mode: '0755' # Optional file permissions
|
||||
owner: ubuntu # Optional ownership
|
||||
group: ubuntu # Optional group ownership
|
||||
|
||||
- name: Create a directory for Nginx website files
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/docker/nginx/web
|
||||
state: directory
|
||||
mode: '0755' # Optional file permissions
|
||||
owner: ubuntu # Optional ownership
|
||||
group: ubuntu # Optional group ownership
|
||||
|
||||
- name: Copy docker-compose to remote host
|
||||
ansible.builtin.copy:
|
||||
src: /home/ubuntu/nginx/docker-compose.yaml
|
||||
dest: /home/ubuntu/ansible-docker/docker-compose/docker-compose.yaml
|
||||
mode: '0755' # Optional file permissions
|
||||
owner: ubuntu # Optional ownership
|
||||
group: ubuntu # Optional group ownership
|
||||
|
||||
- name: Copy Nginx website folder to remote host # copies a folder - note no file extension
|
||||
ansible.builtin.copy:
|
||||
src: /home/ubuntu/nginx/website
|
||||
dest: /home/ubuntu/docker/nginx/web
|
||||
mode: '0755' # Optional file permissions
|
||||
owner: ubuntu # Optional ownership
|
||||
group: ubuntu # Optional group ownership
|
||||
|
||||
- name: Start Docker Compose
|
||||
community.docker.docker_compose:
|
||||
project_src: /home/ubuntu/ansible-docker/docker-compose
|
||||
state: present
|
24
Ansible/Playbooks/File-Copy/File-Copy-Undo-Playbook.yaml
Normal file
24
Ansible/Playbooks/File-Copy/File-Copy-Undo-Playbook.yaml
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
- name: Undo Docker Compose Deployment
|
||||
hosts: all
|
||||
become: true
|
||||
tasks:
|
||||
- name: Stop Docker Container
|
||||
community.docker.docker_compose:
|
||||
project_src: /home/ubuntu/ansible-docker/docker-compose
|
||||
state: absent
|
||||
|
||||
- name: Remove Docker Compose file
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/ansible-docker/docker-compose/docker-compose.yml
|
||||
state: absent
|
||||
|
||||
- name: Remove Docker Compose directory
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/ansible-docker
|
||||
state: absent
|
||||
|
||||
- name: Remove Website directory
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/docker/nginx/web
|
||||
state: absent
|
8
Ansible/Playbooks/File-Copy/inventory.yaml
Normal file
8
Ansible/Playbooks/File-Copy/inventory.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
docker:
|
||||
hosts:
|
||||
docker01:
|
||||
ansible_host: 192.168.200.50
|
||||
ansible_user: 'ubuntu'
|
||||
ansible_become: true
|
||||
ansible_become_method: sudo
|
31
Ansible/Playbooks/File-Copy/nginx/docker-compose.yaml
Normal file
31
Ansible/Playbooks/File-Copy/nginx/docker-compose.yaml
Normal file
|
@ -0,0 +1,31 @@
|
|||
version: "3.9"
|
||||
services:
|
||||
web:
|
||||
image: nginx
|
||||
container_name: jimsgarage
|
||||
volumes:
|
||||
- /home/ubuntu/docker/nginx/templates:/etc/nginx/templates
|
||||
- /home/ubuntu/docker/nginx/web/website:/usr/share/nginx/html
|
||||
environment:
|
||||
- NGINX_HOST=nginx.jimsgarage.co.uk
|
||||
- NGINX_PORT=80
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.nginx.entrypoints=http"
|
||||
- "traefik.http.routers.nginx.rule=Host(`nginx.jimsgarage.co.uk`)"
|
||||
- "traefik.http.middlewares.nginx-https-redirect.redirectscheme.scheme=https"
|
||||
- "traefik.http.routers.nginx.middlewares=nginx-https-redirect"
|
||||
- "traefik.http.routers.nginx-secure.entrypoints=https"
|
||||
- "traefik.http.routers.nginx-secure.rule=Host(`nginx.jimsgarage.co.uk`)"
|
||||
- "traefik.http.routers.nginx-secure.tls=true"
|
||||
- "traefik.http.routers.nginx-secure.service=nginx"
|
||||
- "traefik.http.services.nginx.loadbalancer.server.port=80"
|
||||
- "traefik.docker.network=proxy"
|
||||
networks:
|
||||
proxy:
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
BIN
Ansible/Playbooks/File-Copy/nginx/website/Jims-Garage-1.png
Normal file
BIN
Ansible/Playbooks/File-Copy/nginx/website/Jims-Garage-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 148 KiB |
108
Ansible/Playbooks/File-Copy/nginx/website/index.html
Normal file
108
Ansible/Playbooks/File-Copy/nginx/website/index.html
Normal file
|
@ -0,0 +1,108 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Jim's Garage Ansible Demo</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||
<style>
|
||||
.hero {
|
||||
background: url(Jims-Garage-1.png) no-repeat center center;
|
||||
background-size: cover;
|
||||
height: 400px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
|
||||
.features {
|
||||
margin-top: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.feature {
|
||||
padding: 20px;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.feature:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.footer {
|
||||
background-color: #333;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Navigation Bar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<a class="navbar-brand" href="#">My Webpage</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#home">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#features">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#contact">Contact</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Hero Section -->
|
||||
<div class="hero" id="home">
|
||||
<h1>Welcome to Jim's Garage Ansible Demo</h1>
|
||||
</div>
|
||||
|
||||
<!-- Features Section -->
|
||||
<div class="container features" id="features">
|
||||
<h2>Our Features</h2>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="feature">
|
||||
<i class="fas fa-cogs fa-3x"></i>
|
||||
<h4>Feature 1</h4>
|
||||
<p>Dynamic and interactive elements.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="feature">
|
||||
<i class="fas fa-bolt fa-3x"></i>
|
||||
<h4>Feature 2</h4>
|
||||
<p>Responsive design and transitions.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="feature">
|
||||
<i class="fas fa-heart fa-3x"></i>
|
||||
<h4>Feature 3</h4>
|
||||
<p>Engaging user experiences.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer Section -->
|
||||
<div class="footer">
|
||||
<p>© 2024 My Webpage. All rights reserved.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue