Skip to content

Commit

Permalink
Update capistrano_setup and simplify first_deploy
Browse files Browse the repository at this point in the history
* Create the project directory with the deploy user as owner
(instead of the ansible user). This allows Capistrano to
automatically and dynamically create any shared directories
declared in the project repository (config/deploy.rb, etc.)
* Install gems for the ansible_user so that user can run a
Capistrano deployment from localhost
* Remove project references in the capistano_setup task so it can
be run to build project-agnostic AMIs
  • Loading branch information
mark-dce committed Oct 25, 2021
1 parent 8b4eb5c commit b2883e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 0 additions & 7 deletions roles/capistrano_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,3 @@
groups: deploy
append: yes

- name: "create capistrano skeleton"
become: yes
file: path=/opt/{{ project_name }}/{{ item }} owner=deploy group=deploy state=directory
loop:
- releases
- repo
- shared/config
11 changes: 10 additions & 1 deletion roles/first_deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
path: /home/{{ ansible_ssh_user }}/.ssh/known_hosts
state: absent

- name: "create shared project directory"
become: yes
file: path=/opt/{{ project_name }} owner=deploy group=deploy state=directory

- name: generate rails secret
command: openssl rand -hex 64
register: rails_secret
Expand Down Expand Up @@ -102,6 +106,12 @@
shell: gem install bundler -v "{{ bundler_version }}"
when: bundler_preinstalled.failed

- name: install gems (bundle install)
become: yes
shell: bundle install
args:
chdir: /home/{{ ansible_ssh_user }}/{{ project_name }}

# Set up a keypair so the ansible user can connect as the capistrano deploy user
- name: create deployment keypair for connection user
user:
Expand All @@ -120,7 +130,6 @@
user: deploy
key: "{{ public_key.content | b64decode }}"


- name: ensure ansible user is in the deploy group
become: yes
user:
Expand Down

0 comments on commit b2883e4

Please sign in to comment.