From db95ab05919544ba75b234260a19f704dc89eb24 Mon Sep 17 00:00:00 2001 From: Norman Ziegner Date: Wed, 18 Oct 2023 14:37:03 +0200 Subject: [PATCH] refactor: add role name prefix to variables Signed-off-by: Norman Ziegner --- README.md | 28 ++++++++++++++-------------- defaults/main.yml | 28 ++++++++++++++-------------- tasks/feature-flag.yml | 4 ++-- tasks/install.yml | 8 ++++---- tasks/main.yml | 6 +++--- templates/gitlab.rb.j2 | 28 ++++++++++++++-------------- 6 files changed, 51 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 3301c9d..29dbfa6 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ gitlab_backup_path: '/var/opt/gitlab/backups' Set the port GitLab's web-server Nginx is listening on: ```yaml -nginx_listen_port: '80' +gitlab_nginx_listen_port: '80' ``` #### Does Web-Server Nginx accept HTTPS Requests? @@ -187,7 +187,7 @@ nginx_listen_port: '80' Choose whether GitLab's web-server Nginx accepts HTTPS requests: ```yaml -nginx_listen_https: 'false' +gitlab_nginx_listen_https: 'false' ``` #### Does Web-Server Nginx Redirect HTTP Requests to HTTPS? @@ -195,7 +195,7 @@ nginx_listen_https: 'false' Choose whether GitLab's web-server Nginx redirects HTTP requests to HTTPS: ```yaml -nginx_redirect_http_to_https: 'false' +gitlab_nginx_redirect_http_to_https: 'false' ``` #### Set GitLab feature flags @@ -233,7 +233,7 @@ gitlab_mattermost_only_context: 'false' Set switch to `false` to enable external Redis instance: ```yaml -use_internal_redis: 'false' +gitlab_use_internal_redis: 'false' ``` #### Password to Authenticate Redis Services within Cluster @@ -242,7 +242,7 @@ It is recommended to enable authentication for Redis Master and Redis Replicas by providing the respective password: ```yaml -redis_password: 'changeme' +gitlab_redis_password: 'changeme' ``` _Caution: You have to use your own private and encrypted password here._ @@ -262,7 +262,7 @@ _Caution: You have to use your own private and encrypted password here._ Choose a name of the Redis Cluster for references: ```yaml -redis_cluster_name: 'redis-cluster' +gitlab_redis_cluster_name: 'redis-cluster' ``` #### List of IP addresses of Redis Sentinel Servers @@ -270,7 +270,7 @@ redis_cluster_name: 'redis-cluster' Add a list of IP addresses of the involved Redis Sentinel servers: ```yaml -redis_sentinel_ips: +gitlab_redis_sentinel_ips: - '192.168.33.11' - '192.168.33.12' - '192.168.33.13' @@ -281,7 +281,7 @@ redis_sentinel_ips: Choose port on which Redis Sentinel servers are listening: ```yaml -redis_sentinel_port: '26379' +gitlab_redis_sentinel_port: '26379' ``` #### Whitelist IP Address Range for Monitoring Redis Sentinel Servers @@ -299,7 +299,7 @@ gitlab_ip_range: '{{ ansible_facts.default_ipv4.address }}/24' Set switch to `false` to enable external Gitaly instance: ```yaml -use_internal_gitaly: 'false' +gitlab_use_internal_gitaly: 'false' ``` #### Path to GitLab Data Directory @@ -335,7 +335,7 @@ _Caution: You have to use your own private and encrypted password here._ Specify IP address of the Gitaly instance: ```yaml -gitaly_instance_ip: '127.0.0.1' +gitlab_gitaly_instance_ip: '127.0.0.1' ``` #### Gitaly Port @@ -343,7 +343,7 @@ gitaly_instance_ip: '127.0.0.1' Specify port of the Gitaly instance: ```yaml -gitaly_instance_port: '8075' +gitlab_gitaly_instance_port: '8075' ``` ### Variables to be Set if External PostgreSQL Database is Used @@ -353,7 +353,7 @@ gitaly_instance_port: '8075' Set switch to `false` to enable external PostgreSQL Database instance: ```yaml -use_internal_postgresql: 'false' +gitlab_use_internal_postgresql: 'false' ``` #### IP Address of External PostgreSQL Database Instance @@ -361,7 +361,7 @@ use_internal_postgresql: 'false' Set IP Address of PostgreSQL Database instance: ```yaml -postgresql_db_host: '127.0.0.1' +gitlab_postgresql_db_host: '127.0.0.1' ``` #### Password for External PostgreSQL Database Instance @@ -369,7 +369,7 @@ postgresql_db_host: '127.0.0.1' Set password of PostgreSQL Database instance: ```yaml -postgresql_db_password: 'changeme' +gitlab_postgresql_db_password: 'changeme' ``` _Caution: You have to use your own private and encrypted password here._ diff --git a/defaults/main.yml b/defaults/main.yml index d7d7772..ca45bac 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -30,27 +30,27 @@ gitlab_backup_keep_time: "604800" # Backup directory gitlab_backup_path: "/var/opt/gitlab/backups" # Port for web-requests -nginx_listen_port: "80" +gitlab_nginx_listen_port: "80" # Whether to use https -nginx_listen_https: "false" +gitlab_nginx_listen_https: "false" # Whether to redirect to https -nginx_redirect_http_to_https: "false" +gitlab_nginx_redirect_http_to_https: "false" # Whether to use GitLab Omnibus internal Redis -use_internal_redis: "true" +gitlab_use_internal_redis: "true" # Password for authentication -redis_password: 'changeme' +gitlab_redis_password: 'changeme' # Name of the Redis cluster -redis_cluster_name: 'redis-cluster' +gitlab_redis_cluster_name: 'redis-cluster' # List of IP addresses of Redis Sentinel instances -redis_sentinel_ips: [] +gitlab_redis_sentinel_ips: [] # Port on which Redis Sentinel instances are listening -redis_sentinel_port: "26379" +gitlab_redis_sentinel_port: "26379" # GitLap IP address range gitlab_ip_range: "{{ ansible_facts.default_ipv4.address }}/24" # Whether to use GitLab Omnibus internal Gitaly -use_internal_gitaly: "true" +gitlab_use_internal_gitaly: "true" # Data directory to use gitlab_git_data_dir: "/var/opt/gitlab/git-data" # Gitaly token @@ -58,16 +58,16 @@ gitlab_gitaly_token: 'changeme' # GitLab Shell token gitlab_secret_token: 'changeme' # IP address of the Gitaly instance -gitaly_instance_ip: "127.0.0.1" +gitlab_gitaly_instance_ip: "127.0.0.1" # Port of the Gitaly instance -gitaly_instance_port: "8075" +gitlab_gitaly_instance_port: "8075" # Whether to use GitLab Omnibus internal PostgreSQL database -use_internal_postgresql: "true" +gitlab_use_internal_postgresql: "true" # External PostgreSQL database host IP / domain -postgresql_db_host: "127.0.0.1" +gitlab_postgresql_db_host: "127.0.0.1" # External PostgreSQL database password -postgresql_db_password: "changeme" +gitlab_postgresql_db_password: "changeme" # Whether to enable email gitlab_email_enabled: "false" diff --git a/tasks/feature-flag.yml b/tasks/feature-flag.yml index ae71346..b92c828 100644 --- a/tasks/feature-flag.yml +++ b/tasks/feature-flag.yml @@ -8,13 +8,13 @@ - name: "Check if feature flag is already enabled for {{ gitlab_feature_flag.name }}" ansible.builtin.command: cmd: "gitlab-rails runner 'is_feature_enabled = Feature.enabled?(:{{ gitlab_feature_flag.name }}); puts is_feature_enabled'" - register: "is_feature_enabled" + register: "gitlab_is_feature_enabled" changed_when: false - name: "Enable or disable feature flag {{ gitlab_feature_flag.name }}" ansible.builtin.command: cmd: "gitlab-rails runner 'Feature.{{ 'enable' if gitlab_feature_flag.enabled else 'disable' }}(:{{ gitlab_feature_flag.name }})'" changed_when: true - when: "(is_feature_enabled.stdout == 'true' and not gitlab_feature_flag.enabled) or (is_feature_enabled.stdout == 'false' and gitlab_feature_flag.enabled)" + when: "(gitlab_is_feature_enabled.stdout == 'true' and not gitlab_feature_flag.enabled) or (gitlab_is_feature_enabled.stdout == 'false' and gitlab_feature_flag.enabled)" ... diff --git a/tasks/install.yml b/tasks/install.yml index fa722ea..68f5570 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -19,7 +19,7 @@ url: "{{ gitlab_gpg_key_url }}" id: "{{ gitlab_gpg_key_id }}" state: present - when: not is_initial_dryrun + when: not gitlab_is_initial_dryrun - name: Add GitLab APT repository ansible.builtin.apt_repository: @@ -39,10 +39,10 @@ ansible.builtin.apt: update_cache: true cache_valid_time: 3600 - register: apt_cache + register: gitlab_apt_cache check_mode: false changed_when: - - apt_cache.cache_updated + - gitlab_apt_cache.cache_updated - not ansible_check_mode - name: "Install GitLab on RedHat Like OS" @@ -129,7 +129,7 @@ state: "{{ 'present' if gitlab_version | length > 0 else 'latest' }}" register: gitlab_install_output notify: GitLab has been installed or upgraded - when: not is_initial_dryrun + when: not gitlab_is_initial_dryrun rescue: diff --git a/tasks/main.yml b/tasks/main.yml index ca82746..05e9b99 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,17 +15,17 @@ - name: Determine if this is an initial dry-run ansible.builtin.set_fact: - is_initial_dryrun: "{{ ansible_check_mode and not gitlab_rails_binary.stat.exists }}" + gitlab_is_initial_dryrun: "{{ ansible_check_mode and not gitlab_rails_binary.stat.exists }}" - name: Check if a previous reconfigure had failed ansible.builtin.stat: path: /etc/gitlab/reconfigure_failed - register: reconfigure_failed + register: gitlab_reconfigure_failed - name: Reconfigure GitLab ansible.builtin.import_tasks: reconfigure.yml become: yes - when: reconfigure_failed.stat.exists + when: gitlab_reconfigure_failed.stat.exists - name: Install GitLab ansible.builtin.import_tasks: install.yml diff --git a/templates/gitlab.rb.j2 b/templates/gitlab.rb.j2 index 9ab44bd..01e9749 100644 --- a/templates/gitlab.rb.j2 +++ b/templates/gitlab.rb.j2 @@ -10,18 +10,18 @@ gitlab_rails['time_zone'] = "{{ gitlab_time_zone }}" gitlab_rails['backup_keep_time'] = "{{ gitlab_backup_keep_time }}" gitlab_rails['backup_path'] = "{{ gitlab_backup_path }}" -nginx['listen_port'] = "{{ nginx_listen_port }}" -nginx['listen_https'] = {{ nginx_listen_https }} -nginx['redirect_http_to_https'] = {{ nginx_redirect_http_to_https }} +nginx['listen_port'] = "{{ gitlab_nginx_listen_port }}" +nginx['listen_https'] = {{ gitlab_nginx_listen_https }} +nginx['redirect_http_to_https'] = {{ gitlab_nginx_redirect_http_to_https }} -{% if not use_internal_redis %} +{% if not gitlab_use_internal_redis %} redis['enable'] = false -gitlab_rails['redis_password'] = "{{ redis_password }}" -redis['master_name'] = "{{ redis_cluster_name }}" -redis['master_password'] = "{{ redis_password }}" +gitlab_rails['redis_password'] = "{{ gitlab_redis_password }}" +redis['master_name'] = "{{ gitlab_redis_cluster_name }}" +redis['master_password'] = "{{ gitlab_redis_password }}" gitlab_rails['redis_sentinels'] = [ -{% for redis_sentinel_ip in redis_sentinel_ips %} - { "host" => "{{ redis_sentinel_ip }}", "port" => "{{ redis_sentinel_port }}" }, +{% for redis_sentinel_ip in gitlab_redis_sentinel_ips %} + { "host" => "{{ redis_sentinel_ip }}", "port" => "{{ gitlab_redis_sentinel_port }}" }, {% endfor %} ] {% if gitlab_redis_sentinel_password | default('') | length %} @@ -30,14 +30,14 @@ gitlab_rails['redis_sentinels_password'] = "{{ gitlab_redis_sentinel_password }} {% endif %} gitlab_rails['monitoring_whitelist'] = ["{{ gitlab_ip_range }}"] -{% if use_internal_gitaly %} +{% if gitlab_use_internal_gitaly %} git_data_dirs({"default" => {"path" => "{{ gitlab_git_data_dir }}"} }) {% else %} gitaly['enable'] = false gitlab_rails['gitaly_token'] = "{{ gitlab_gitaly_token }}" gitlab_shell['secret_token'] = "{{ gitlab_secret_token }}" git_data_dirs({ - 'default' => { 'gitaly_address' => 'tcp://{{ gitaly_instance_ip }}:{{ gitaly_instance_port }}' }, + 'default' => { 'gitaly_address' => 'tcp://{{ gitlab_gitaly_instance_ip }}:{{ gitlab_gitaly_instance_port }}' }, }) {% endif %} @@ -47,14 +47,14 @@ gitlab_rails['smtp_enable'] = {{ gitlab_smtp_enable }} registry['enable'] = {{ gitlab_registry_enable }} -{% if not use_internal_postgresql %} +{% if not gitlab_use_internal_postgresql %} # Disable the bundled Omnibus provided PostgreSQL postgresql['enable'] = false # PostgreSQL connection details gitlab_rails['db_adapter'] = 'postgresql' gitlab_rails['db_encoding'] = 'unicode' -gitlab_rails['db_host'] = "{{ postgresql_db_host }}" -gitlab_rails['db_password'] = "{{ postgresql_db_password }}" +gitlab_rails['db_host'] = "{{ gitlab_postgresql_db_host }}" +gitlab_rails['db_password'] = "{{ gitlab_postgresql_db_password }}" {% endif %} {#