mirror of
https://github.com/JamesTurland/JimsGarage.git
synced 2024-11-21 15:30:19 +00:00
ansible secrets and variables
This commit is contained in:
parent
8623f316a6
commit
83ca476110
3 changed files with 69 additions and 0 deletions
67
Ansible/Playbooks/Secrets-Variables/File-Copy-Playbook.yaml
Normal file
67
Ansible/Playbooks/Secrets-Variables/File-Copy-Playbook.yaml
Normal file
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
- name: Deploy Docker Container with Docker Compose
|
||||
hosts: all
|
||||
become: true
|
||||
tasks:
|
||||
- name: Include variables file
|
||||
ansible.builtin.include_vars: myvars.yaml
|
||||
|
||||
- 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: Replace old name with new name (requires Ansible >= 2.4)
|
||||
ansible.builtin.replace:
|
||||
path: /home/ubuntu/docker/nginx/web/website/index.html
|
||||
regexp: "Jim's Garage"
|
||||
replace: "{{ website_name }}"
|
||||
|
||||
- name: Access and print secret
|
||||
ansible.builtin.replace:
|
||||
path: /home/ubuntu/docker/nginx/web/website/index.html
|
||||
regexp: "Our Features"
|
||||
replace: "{{ api_key }}"
|
||||
|
||||
- name: Start Docker Compose
|
||||
community.docker.docker_compose:
|
||||
project_src: /home/ubuntu/ansible-docker/docker-compose
|
||||
state: present
|
1
Ansible/Playbooks/Secrets-Variables/password
Normal file
1
Ansible/Playbooks/Secrets-Variables/password
Normal file
|
@ -0,0 +1 @@
|
|||
password
|
1
Ansible/Playbooks/Secrets-Variables/secrets_file.enc
Normal file
1
Ansible/Playbooks/Secrets-Variables/secrets_file.enc
Normal file
|
@ -0,0 +1 @@
|
|||
api_key: SuperSecretPassword
|
Loading…
Reference in a new issue