Advertisement
PandaAcademy

playbook.yml

May 28th, 2022 (edited)
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.13 KB | None | 0 0
  1. ---
  2. - name: Deploy application
  3.   hosts: all
  4.   become: true
  5.   vars:
  6.     deployment_path: "/home/ubuntu/app"
  7.     compose_path: "./docker-compose.yml"
  8.   roles:
  9.    - geerlingguy.docker
  10.   tasks:
  11.     - name: Update apt-get repo and cache
  12.       apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
  13.    
  14.     - name: Install packages
  15.       package:
  16.         name:
  17.           - python3-pip
  18.         state: present
  19.    
  20.     - name: Install docker-compose python package
  21.       pip:
  22.         name:
  23.         - docker<7.0
  24.         - docker-compose
  25.     - name: Create a directory if it does not exist
  26.       file:
  27.         path: "{{ deployment_path }}"
  28.         state: directory
  29.         mode: '0755'
  30.  
  31.     - name: Copy docker compose
  32.       copy:
  33.         src: "{{ compose_path }}"
  34.         dest: "{{ deployment_path }}"
  35.  
  36.     - name: Run `docker-compose up`
  37.       become: true
  38.       docker_compose:
  39.         project_src: "{{ deployment_path }}"
  40.         build: yes
  41.         debug: yes
  42.       environment:
  43.         FRONTEND_IMAGE: "{{ lookup('env','FRONTEND_IMAGE') }}"
  44.         BACKEND_IMAGE: "{{ lookup('env','BACKEND_IMAGE') }}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement