diff --git a/Ansible/Playbooks/File-Copy/File-Copy-Playbook.yaml b/Ansible/Playbooks/File-Copy/File-Copy-Playbook.yaml new file mode 100644 index 0000000..4eaf2ea --- /dev/null +++ b/Ansible/Playbooks/File-Copy/File-Copy-Playbook.yaml @@ -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 diff --git a/Ansible/Playbooks/File-Copy/File-Copy-Undo-Playbook.yaml b/Ansible/Playbooks/File-Copy/File-Copy-Undo-Playbook.yaml new file mode 100644 index 0000000..52118a1 --- /dev/null +++ b/Ansible/Playbooks/File-Copy/File-Copy-Undo-Playbook.yaml @@ -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 diff --git a/Ansible/Playbooks/File-Copy/inventory.yaml b/Ansible/Playbooks/File-Copy/inventory.yaml new file mode 100644 index 0000000..34d1a72 --- /dev/null +++ b/Ansible/Playbooks/File-Copy/inventory.yaml @@ -0,0 +1,8 @@ +--- +docker: + hosts: + docker01: + ansible_host: 192.168.200.50 + ansible_user: 'ubuntu' + ansible_become: true + ansible_become_method: sudo diff --git a/Ansible/Playbooks/File-Copy/nginx/docker-compose.yaml b/Ansible/Playbooks/File-Copy/nginx/docker-compose.yaml new file mode 100644 index 0000000..b0812b9 --- /dev/null +++ b/Ansible/Playbooks/File-Copy/nginx/docker-compose.yaml @@ -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 \ No newline at end of file diff --git a/Ansible/Playbooks/File-Copy/nginx/website/Jims-Garage-1.png b/Ansible/Playbooks/File-Copy/nginx/website/Jims-Garage-1.png new file mode 100644 index 0000000..d5491ac Binary files /dev/null and b/Ansible/Playbooks/File-Copy/nginx/website/Jims-Garage-1.png differ diff --git a/Ansible/Playbooks/File-Copy/nginx/website/index.html b/Ansible/Playbooks/File-Copy/nginx/website/index.html new file mode 100644 index 0000000..9deb299 --- /dev/null +++ b/Ansible/Playbooks/File-Copy/nginx/website/index.html @@ -0,0 +1,108 @@ + + +
+ +Dynamic and interactive elements.
+Responsive design and transitions.
+Engaging user experiences.
+