Skip to content

Commit

Permalink
Merge pull request #188 from consul/group_name
Browse files Browse the repository at this point in the history
Allow configuring the group used by the deploy user
  • Loading branch information
javierm authored Nov 5, 2021
2 parents ce24afe + ee98ffd commit 9699c15
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ If you do not have `root` access, you will need your system administrator to gra

## Using a different user than deploy

Change the variable [deploy_user](https://github.com/consul/installer/blob/1.3.1/group_vars/all#L12) to the username you would like to use.
Change the variable [deploy_user](https://github.com/consul/installer/blob/1.3.1/group_vars/all#L13) to the username you would like to use.

## Ansible Documentation

Expand Down
1 change: 1 addition & 0 deletions group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ locale: en_US.UTF-8
# General settings
env: production
deploy_user: deploy
deploy_group: wheel
home_dir: "/home/{{ deploy_user }}"
deploy_server_hostname: 127.0.0.1
consul_dir: "{{ home_dir }}/{{ app_name }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/errbit/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
src: "{{ playbook_dir }}/roles/errbit/templates/errbit.example.com"
dest: /etc/nginx/sites-enabled/errbit
owner: "{{ deploy_user }}"
group: wheel
group: "{{ deploy_group }}"

- name: Restart Nginx
become: true
Expand Down
2 changes: 1 addition & 1 deletion roles/letsencrypt/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
src: "{{ playbook_dir }}/roles/letsencrypt/templates/options-ssl-nginx.conf"
dest: /etc/letsencrypt/options-ssl-nginx.conf
owner: "{{ deploy_user }}"
group: wheel
group: "{{ deploy_group }}"

- name: Generate /etc/ssl/certs/dhparam.pem (this may take a few minutes)
command: openssl dhparam -out /etc/letsencrypt/ssl-dhparams.pem 2048
2 changes: 1 addition & 1 deletion roles/nginx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
src: "{{ playbook_dir }}/roles/nginx/templates/consul_vhost.j2"
dest: /etc/nginx/sites-enabled/default
owner: "{{ deploy_user }}"
group: wheel
group: "{{ deploy_group }}"

- name: Restart Nginx
service:
Expand Down
12 changes: 6 additions & 6 deletions roles/user/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
- name: Make sure we have a 'wheel' group
- name: Make sure we have a '{{ deploy_group }}' group
group:
name: wheel
name: "{{ deploy_group }}"
state: present

- name: Allow 'wheel' group to have passwordless sudo
- name: Allow '{{ deploy_group }}' group to have passwordless sudo
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) NOPASSWD: ALL'
regexp: '^%{{ deploy_group }}'
line: '%{{ deploy_group }} ALL=(ALL) NOPASSWD: ALL'

- name: Create the deploy user
user:
name: "{{ deploy_user }}"
group: wheel
group: "{{ deploy_group }}"
state: present
shell: /bin/bash

Expand Down
2 changes: 1 addition & 1 deletion user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
hosts: all
become: yes
roles:
- { role: user, when: ansible_user != "deploy" }
- { role: user, when: ansible_user != deploy_user }

0 comments on commit 9699c15

Please sign in to comment.