Skip to content

Commit

Permalink
working on zsh and drupal
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed Apr 17, 2024
1 parent 9a3c295 commit 82fcb88
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
2 changes: 2 additions & 0 deletions roles/drupal/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ drupal_base_url: ''
drupal_maintenance_theme: ''
drupal_fast_404: false

# instance.drupal_user is required for zsh, too
drupal_with_zsh: true
drupal_with_memcache: false
drupal_memcache_module: sites/all/modules/contrib/memcache
drupal_memcache_prefix: drupal
Expand Down
36 changes: 25 additions & 11 deletions roles/drupal/tasks/instance.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
---

- name: Include zsh role
ansible.builtin.include_role:
name: alphanodes.setup.zsh
vars:
zsh_user: '{{ instance.drupal_user }}'
zsh_with_setup: false
zsh_user_home: '{{ instance.dir }}'
when: drupal_with_zsh and instance.drupal_user is defined

- name: Include mysql tasks
ansible.builtin.include_tasks: instance_mysql.yml
tags: mysql
Expand All @@ -24,10 +33,14 @@
accept_hostkey: true
force: true
when: instance.repo is defined
become: '{{ true if instance.drupal_user is defined else false }}'
become_user: '{{ instance.drupal_user | default('') }}'
register: git_result

- name: Run post commands

Check failure on line 40 in roles/drupal/tasks/instance.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[invalid]

template error while templating string: unexpected char "'" at 34. String: {{ instance.drupal_user | default(') }}. unexpected char "'" at 34
ansible.builtin.command: "{{ item | replace('[drush]', '{{ instance.drush_path | default(drupal_drush_path) }} @{{ instance.name }}') }}"
become: '{{ true if instance.drupal_user is defined else false }}'
become_user: '{{ instance.drupal_user | default('') }}'
loop: "{{ instance.post_commands }}"
when:
- git_result.changed
Expand All @@ -47,15 +60,16 @@
ansible.builtin.file:
path: '{{ instance.dir }}{{ item }}'
owner: '{{ nginx_user }}'
group: '{{ nginx_group }}'
group: '{{ instance.drupal_group | default(nginx_group) }}'
recurse: true
loop: '{{ instance.write_permissions | default([]) }}'
when: drupal_user is not defined

- name: Make sure tmp directory exists and permissions are correct - {{ instance.name }}
ansible.builtin.file:
path: '{{ instance.dir }}{{ instance.tmp_dir }}'
owner: '{{ nginx_user }}'
group: '{{ nginx_group }}'
owner: '{{ instance.drupal_user | default(nginx_user) }}'
group: '{{ instance.drupal_group | default(nginx_group) }}'
state: directory
recurse: true
when: instance.tmp_dir is defined
Expand All @@ -74,24 +88,24 @@
- name: Set private files permissions - {{ instance.name }}
ansible.builtin.file:
path: '{{ file_private_path }}'
owner: '{{ nginx_user }}'
group: '{{ nginx_group }}'
owner: '{{ instance.drupal_user | default(nginx_user) }}'
group: '{{ instance.drupal_group | default(nginx_group) }}'
recurse: true

- name: Set configuration sync permissions - {{ instance.name }}
ansible.builtin.file:
path: '{{ config_sync_directory }}'
owner: '{{ nginx_user }}'
group: '{{ nginx_group }}'
owner: '{{ instance.drupal_user | default(nginx_user) }}'
group: '{{ instance.drupal_group | default(nginx_group) }}'
recurse: true

- name: Update settings.php for Drupal - {{ instance.name }}
ansible.builtin.template:
src: default.settings.php.j2
dest: "{{ instance.dir }}{{ instance.vhost_dir | default(drupal_vhost_dir) }}/sites/default/settings.php"
validate: 'php -l %s'
owner: root
group: '{{ nginx_group }}'
owner: '{{ instance.drupal_user | default("root") }}'
group: '{{ instance.drupal_group | default(nginx_group) }}'
mode: 0640
when:
- instance.write_settings_file is not defined or instance.write_settings_file
Expand All @@ -100,8 +114,8 @@
ansible.builtin.template:
src: env.j2
dest: "{{ instance.dir }}/.env"
owner: '{{ nginx_user }}'
group: '{{ nginx_group }}'
owner: '{{ instance.drupal_user | default("root") }}'
group: '{{ instance.drupal_group | default(nginx_group) }}'
mode: 0640

- name: Check trusted TLS cert
Expand Down
4 changes: 4 additions & 0 deletions roles/zsh/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ zsh_with_zshrc: true
zsh_with_ruby: false
# with active rvm
zsh_with_rvm: false
# for composer vendor suport (drupal)
zsh_with_composer: false
zsh_with_completions: true
zsh_with_powerlevel10k: true
zsh_powerlevel10k_packages:
- fonts-powerline

zsh_user: root

zsh_default_shell: true

# used in .zshrc
zsh_global_exports: []
zsh_local_exports: []
Expand Down
6 changes: 6 additions & 0 deletions roles/zsh/tasks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@
src: auto-ls.zsh
dest: '{{ auto_ls_plugin_file }}'
mode: 0644

- name: Set zsh as default shell

Check failure on line 41 in roles/zsh/tasks/setup.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

fqcn[action-core]

Use FQCN for builtin module actions (user).
user:
name: "{{ ansible_user }}"
shell: /usr/bin/zsh
when: zsh_default_shell
6 changes: 5 additions & 1 deletion roles/zsh/templates/zshrc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ export HISTORY_IGNORE="{{ zsh_history_ignore }}"
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
{% endif %}
{% for export_info in zsh_global_exports %}
{% if zsh_with_composer %}
# Add vendor bin directory with composer usage.
export PATH="$PATH:$HOME/vendor/bin"
{% endif %}
{% for exportwith_composer_info in zsh_global_exports %}
export {{ export_info.name }}={{ export_info.value }}
{% endfor %}
{% for export_info in zsh_local_exports %}
Expand Down

0 comments on commit 82fcb88

Please sign in to comment.