Skip to content

Commit

Permalink
File permissions: Use strings instead of octal numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrufus authored and kennyr87 committed Oct 21, 2021
1 parent fdb1eee commit ee71e02
Show file tree
Hide file tree
Showing 26 changed files with 57 additions and 57 deletions.
4 changes: 2 additions & 2 deletions roles/deploy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ project_templates:
- name: .env config
src: roles/deploy/templates/env.j2
dest: .env
mode: 0600
mode: '0600'

# The shared_children is a list of all files/folders in your project that need to be linked to a path in `/shared`.
# For example a sessions directory or an uploads folder. They are created if they don't exist, with the type
Expand All @@ -29,7 +29,7 @@ project_templates:
# project_shared_children:
# - path: app/sessions
# src: sessions
# mode: 0755 // <- optional, use an octal number starting with 0 or quote it, defaults to `0755` if `directory` or `0644` if `file`
# mode: '0755' // <- optional, use an octal number starting with 0 or quote it, defaults to `'0755'` if `directory` or `'0644'` if `file`
# type: directory // <- optional, defaults to `directory`, options: `directory` or `file`
project_shared_children:
- path: web/app/uploads
Expand Down
2 changes: 1 addition & 1 deletion roles/deploy/tasks/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
template:
src: "{{ item.src }}"
dest: "{{ deploy_helper.new_release_path }}/{{ item.dest }}"
mode: "{{ item.mode | default(0644) }}"
mode: "{{ item.mode | default('0644') }}"
with_items: "{{ project.project_templates | default(project_templates) }}"

- name: Check if project folders exist
Expand Down
4 changes: 2 additions & 2 deletions roles/deploy/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- name: Create new release dir
file:
path: "{{ deploy_helper.new_release_path }}"
mode: 0755
mode: '0755'
state: directory

- name: Run git archive
Expand All @@ -51,7 +51,7 @@
- name: write unfinished file
file:
path: "{{ deploy_helper.new_release_path }}/{{ deploy_helper.unfinished_filename }}"
mode: 0744
mode: '0744'
state: touch

- name: Check if deploy_prepare_after scripts exist
Expand Down
8 changes: 4 additions & 4 deletions roles/deploy/tasks/share.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
file:
path: "{{ deploy_helper.shared_path }}/{{ item.src }}"
state: directory
mode: "{{ item.mode | default(0755) }}"
mode: "{{ item.mode | default('0755') }}"
with_items: "{{ project.project_shared_children | default(project_shared_children) }}"
when: item.type | default('directory') | lower == 'directory'

- name: Ensure shared sources are present -- files' parent directories
file:
path: "{{ deploy_helper.shared_path }}/{{ item.src | dirname }}"
state: directory
mode: 0755
mode: '0755'
with_items: "{{ project.project_shared_children | default(project_shared_children) }}"
when: item.type | default('directory') | lower == 'file'

- name: Ensure shared sources are present -- files
file:
path: "{{ deploy_helper.shared_path }}/{{ item.src }}"
state: touch
mode: "{{ item.mode | default(0644) }}"
mode: "{{ item.mode | default('0644') }}"
with_items: "{{ project.project_shared_children | default(project_shared_children) }}"
when: item.type | default('directory') | lower == 'file'

- name: Ensure parent directories for shared paths are present
file:
path: "{{ deploy_helper.new_release_path }}/{{ item.path | dirname }}"
mode: 0777
mode: '0777'
state: directory
with_items: "{{ project.project_shared_children | default(project_shared_children) }}"

Expand Down
6 changes: 3 additions & 3 deletions roles/fail2ban/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
template:
src: "{{ item }}.j2"
dest: /etc/fail2ban/{{ item }}
mode: 0644
mode: '0644'
with_items:
- jail.local
- fail2ban.local
Expand All @@ -31,13 +31,13 @@
file:
path: /etc/fail2ban/filter.d/
state: directory
mode: 0755
mode: '0755'

- name: template fail2ban filters
template:
src: "{{ item }}"
dest: "/etc/fail2ban/filter.d/{{ item | regex_replace(fail2ban_filter_templates_pattern, '\\2') }}"
mode: 0644
mode: '0644'
with_items: "{{ fail2ban_filter_templates.files | map(attribute='path') | list | sort(True) }}"
notify: restart fail2ban

Expand Down
4 changes: 2 additions & 2 deletions roles/ferm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
file:
path: "{{ item }}"
state: directory
mode: 0750
mode: '0750'
with_items:
- /etc/ferm/ferm.d
- /etc/ferm/filter-input.d
Expand All @@ -28,7 +28,7 @@
template:
src: "{{ item }}.j2"
dest: /{{ item }}
mode: 0644
mode: '0644'
with_items:
- etc/default/ferm
- etc/ferm/ferm.conf
Expand Down
4 changes: 2 additions & 2 deletions roles/letsencrypt/tasks/certificates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- name: Ensure correct permissions on private keys
file:
path: "{{ letsencrypt_keys_dir }}/{{ item.key }}.key"
mode: 0600
mode: '0600'
when: site_uses_letsencrypt
with_dict: "{{ wordpress_sites }}"

Expand Down Expand Up @@ -39,7 +39,7 @@
template:
src: renew-certs.py
dest: "{{ acme_tiny_data_directory }}/renew-certs.py"
mode: 0700
mode: '0700'
tags: [wordpress, wordpress-setup, wordpress-setup-nginx, nginx-includes]

- name: Generate the certificates
Expand Down
6 changes: 3 additions & 3 deletions roles/letsencrypt/tasks/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
template:
src: acme-challenge-location.conf.j2
dest: "{{ nginx_path }}/acme-challenge-location.conf"
mode: 0644
mode: '0644'

- name: Get list of hosts in current Nginx conf
shell: |
Expand All @@ -18,7 +18,7 @@
template:
src: nginx-challenge-site.conf.j2
dest: "{{ nginx_path }}/sites-available/letsencrypt-{{ item.key }}.conf"
mode: 0644
mode: '0644'
register: challenge_site_confs
when:
- site_uses_letsencrypt
Expand All @@ -44,7 +44,7 @@
file:
path: "{{ acme_tiny_challenges_directory }}/ping.txt"
state: touch
mode: 0644
mode: '0644'

- name: Test Acme Challenges
test_challenges:
Expand Down
8 changes: 4 additions & 4 deletions roles/letsencrypt/tasks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
state: directory
with_items:
- path: "{{ acme_tiny_data_directory }}"
mode: 0700
mode: '0700'
- path: "{{ acme_tiny_data_directory }}/csrs"
- path: "{{ acme_tiny_software_directory }}"
- path: "{{ acme_tiny_challenges_directory }}"
- path: "{{ letsencrypt_certs_dir }}"
mode: 0700
mode: '0700'

- name: Clone acme-tiny repository
git:
Expand All @@ -46,14 +46,14 @@
copy:
src: "{{ letsencrypt_account_key_source_file }}"
dest: "{{ letsencrypt_account_key }}"
mode: 0700
mode: '0700'
when: letsencrypt_account_key_source_file is defined

- name: Copy Lets Encrypt account key source contents
copy:
content: "{{ letsencrypt_account_key_source_content | trim }}"
dest: "{{ letsencrypt_account_key }}"
mode: 0700
mode: '0700'
when: letsencrypt_account_key_source_content is defined

- name: Generate a new account key
Expand Down
4 changes: 2 additions & 2 deletions roles/mariadb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
dest: /etc/mysql/conf.d
owner: root
group: root
mode: 0644
mode: '0644'
when: mysql_binary_logging_disabled | bool
notify: restart mysql server

Expand All @@ -53,7 +53,7 @@
dest: ~/.my.cnf
owner: root
group: root
mode: 0600
mode: '0600'

- name: Delete anonymous MySQL server users
mysql_user:
Expand Down
2 changes: 1 addition & 1 deletion roles/memcached/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
template:
src: memcached.conf.j2
dest: /etc/memcached.conf
mode: 0644
mode: '0644'
notify: restart memcached

- name: Set the max open file descriptors
Expand Down
8 changes: 4 additions & 4 deletions roles/nginx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
file:
path: "{{ nginx_path }}/{{ item }}"
state: directory
mode: 0755
mode: '0755'
with_items:
- sites-available
- sites-enabled

- name: Create SSL directory
file:
mode: 0700
mode: '0700'
path: "{{ nginx_path }}/ssl"
state: directory

Expand All @@ -43,14 +43,14 @@
copy:
src: templates/h5bp
dest: "{{ nginx_path }}"
mode: 0755
mode: '0755'
notify: reload nginx

- name: Create nginx.conf
template:
src: "{{ nginx_conf }}"
dest: "{{ nginx_path }}/nginx.conf"
mode: 0644
mode: '0644'
notify: reload nginx
tags: nginx-includes

Expand Down
4 changes: 2 additions & 2 deletions roles/php/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
template:
src: php-fpm.ini.j2
dest: /etc/php/7.4/fpm/php.ini
mode: 0644
mode: '0644'
notify: reload php-fpm

- name: Copy PHP CLI configuration file
template:
src: php-cli.ini.j2
dest: /etc/php/7.4/cli/php.ini
mode: 0644
mode: '0644'
2 changes: 1 addition & 1 deletion roles/rollback/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
file:
path: "{{ current_release_readlink_result.stdout }}/DEPLOY_UNFINISHED"
state: touch
mode: 0644
mode: '0644'
4 changes: 2 additions & 2 deletions roles/sshd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
template:
src: "{{ sshd_config }}"
dest: /etc/ssh/sshd_config
mode: 0600
mode: '0600'
validate: '/usr/sbin/sshd -T -f %s'
notify: restart ssh

- name: Create a secure ssh_config
template:
src: "{{ ssh_config }}"
dest: /etc/ssh/ssh_config
mode: 0644
mode: '0644'

- name: Remove Diffie-Hellman moduli of size < 2000
lineinfile:
Expand Down
4 changes: 2 additions & 2 deletions roles/ssmtp/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
template:
src: ssmtp.conf.j2
dest: /etc/ssmtp/ssmtp.conf
mode: 0644
mode: '0644'

- name: ssmtp revaliases configuration
template:
src: revaliases.j2
dest: /etc/ssmtp/revaliases
mode: 0644
mode: '0644'
2 changes: 1 addition & 1 deletion roles/users/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
template:
src: sudoers.d.j2
dest: "/etc/sudoers.d/{{ web_user }}-services"
mode: 0440
mode: '0440'
owner: root
group: root
validate: "/usr/sbin/visudo -cf %s"
Expand Down
6 changes: 3 additions & 3 deletions roles/wordpress-install/tasks/directories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
path: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/web"
owner: "{{ web_user }}"
group: "{{ web_group }}"
mode: 0755
mode: '0755'
state: directory
with_dict: "{{ wordpress_sites }}"

Expand All @@ -13,7 +13,7 @@
path: "{{ www_root }}/{{ item.key }}/shared"
owner: "{{ web_user }}"
group: "{{ web_group }}"
mode: 0755
mode: '0755'
state: directory
with_dict: "{{ wordpress_sites }}"

Expand All @@ -22,7 +22,7 @@
path: "{{ www_root }}/{{ item.key }}"
owner: "{{ web_user }}"
group: "{{ web_group }}"
mode: 0755
mode: '0755'
state: directory
recurse: yes
with_dict: "{{ wordpress_sites }}"
2 changes: 1 addition & 1 deletion roles/wordpress-install/tasks/dotenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
template:
src: "env.j2"
dest: "/tmp/{{ item.key }}.env"
mode: 0644
mode: '0644'
owner: "{{ web_user }}"
group: "{{ web_group }}"
with_dict: "{{ wordpress_sites }}"
Expand Down
6 changes: 3 additions & 3 deletions roles/wordpress-setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
path: "{{ www_root }}"
owner: "{{ web_user }}"
group: "{{ web_group }}"
mode: 0755
mode: '0755'
state: directory

- name: Create logs folder of sites
file:
path: "{{ www_root }}/{{ item.key }}/logs"
owner: "{{ web_user }}"
group: "{{ web_group }}"
mode: 0755
mode: '0755'
state: directory
with_dict: "{{ wordpress_sites }}"

- name: Create WordPress php-fpm configuration file
template:
src: php-fpm.conf.j2
dest: /etc/php/7.4/fpm/pool.d/wordpress.conf
mode: 0644
mode: '0644'
notify: reload php-fpm

- name: Disable default PHP-FPM pool
Expand Down
2 changes: 1 addition & 1 deletion roles/wordpress-setup/tasks/nginx-client-cert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
get_url:
url: "{{ item.value.ssl.client_cert_url }}"
dest: "{{ nginx_ssl_path }}/client-{{ (item.value.ssl.client_cert_url | hash('md5'))[:7] }}.crt"
mode: 0640
mode: '0640'
with_dict: "{{ wordpress_sites }}"
when: ssl_enabled and item.value.ssl.client_cert_url is defined
Loading

0 comments on commit ee71e02

Please sign in to comment.