---
  - name: Install rails apt dependencies
    apt:
      name: "{{item}}"
    with_items:
      - git
      - imagemagick
      - libffi-dev
      - libgmp3-dev
      - libmagickwand-dev
      - libpq-dev
      - libxslt-dev
      - nodejs
      - zlib1g-dev
    become: true

  - name: Create /u/apps/{{project_name}}/shared/config
    file:
      path: /u/apps/{{project_name}}/shared/config/
      state: directory
    become: true
    become_user: "{{deploy_user}}"

  - name: Create database.yml
    template:
      src: database.yml
      dest: /u/apps/{{project_name}}/shared/config/database.yml
      owner: "{{deploy_user}}"
    become: true

  - name: Create application.yml (legacy)
    when: appyml is defined
    template:
      src: application.yml
      dest: /u/apps/{{project_name}}/shared/config/application.yml
      owner: "{{deploy_user}}"
    become: true

  - debug:
      msg: "Warning: Using legacy appyml for variable configuration.  Consider switching to application.yml.template"
      verbosity: 0
    when: appyml is defined

  - name: Create application.yml
    when: appyml is not defined
    template:
      src: application.yml.template
      dest: /u/apps/{{project_name}}/shared/config/application.yml
      owner: "{{deploy_user}}"


---
  - name: Add yarn apt key
    apt_key:
      url: https://dl.yarnpkg.com/debian/pubkey.gpg
      state: present

  - name: Add yarn apt repo
    apt_repository:
      repo: deb https://dl.yarnpkg.com/debian/ stable main
      state: present

  - name: Install rails apt dependencies
    apt:
      name: "{{item}}"
    with_items:
      - git
      - imagemagick
      - libffi-dev
      - libgmp3-dev
      - libmagickwand-dev
      - libpq-dev
      - libxslt-dev
      - nodejs
      - zlib1g-dev
      - yarn
    become: true

  - name: Create /u/apps/{{project_name}}/shared/config
    file:
      path: /u/apps/{{project_name}}/shared/config/
      state: directory
    become: true
    become_user: "{{deploy_user}}"

  - name: Create database.yml
    template:
      src: database.yml
      dest: /u/apps/{{project_name}}/shared/config/database.yml
      owner: "{{deploy_user}}"
    become: true

  - name: Create application.yml (legacy)
    when: appyml is defined
    template:
      src: application.yml
      dest: /u/apps/{{project_name}}/shared/config/application.yml
      owner: "{{deploy_user}}"
    become: true

  - debug:
      msg: "Warning: Using legacy appyml for variable configuration.  Consider switching to application.yml.template"
      verbosity: 0
    when: appyml is defined

  - name: Create application.yml
    when: appyml is not defined
    template:
      src: application.yml.template
      dest: /u/apps/{{project_name}}/shared/config/application.yml
      owner: "{{deploy_user}}"


Install yarn as part of rails role
Install yarn as part of rails role
