diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-08-05 11:57:19 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-08-05 13:23:58 +0300 |
commit | 5b296c0be8158e973fa1b916542f20ddff8b6c9b (patch) | |
tree | 7a482e15b730f1fe7cb393de045868cf886af4ba /_support/terraform/roles/gitlab | |
parent | 54ca71696b00e80613f3b7c2ac50e967fa706045 (diff) |
terraform: Create Ansible playbook to roll out configuration
Right now, our Terraform scripts only handle creation of machines in
GCP, but not their respective configuration. As it's a task we're doing
rather frequently which takes some time, this commit creates an Ansible
playbook which automates this task.
On creation of the cluster, our scripts now automatically generate a
`hosts.ini` file containing all necessary connection information. With
this file, the admin may now run `./configure-demo-cluster`, which will
invoke Ansible and automatically generate and apply configuration for
each of the nodes, restarting services as required. The task can be run
repeatedly in order to update configuration on the target nodes.
Diffstat (limited to '_support/terraform/roles/gitlab')
-rw-r--r-- | _support/terraform/roles/gitlab/handlers/main.yml | 18 | ||||
-rw-r--r-- | _support/terraform/roles/gitlab/tasks/main.yml | 15 | ||||
-rw-r--r-- | _support/terraform/roles/gitlab/templates/gitlab-gitlab.rb.j2 | 37 |
3 files changed, 70 insertions, 0 deletions
diff --git a/_support/terraform/roles/gitlab/handlers/main.yml b/_support/terraform/roles/gitlab/handlers/main.yml new file mode 100644 index 000000000..0c2b34ec2 --- /dev/null +++ b/_support/terraform/roles/gitlab/handlers/main.yml @@ -0,0 +1,18 @@ +- name: wait gitlab + uri: + url: "http://{{ groups.gitlabs[0] }}" + register: result + until: result.status == 200 + retries: 60 + delay: 5 + changed_when: false + +- name: verify gitaly configuration + command: + cmd: gitlab-rake gitlab:gitaly:check + +- name: verify gitlab-shell + command: + cmd: /opt/gitlab/embedded/service/gitlab-shell/bin/check -config /opt/gitlab/embedded/service/gitlab-shell/config.yml + delegate_to: '{{ item }}' + with_items: '{{ groups.gitalies }}' diff --git a/_support/terraform/roles/gitlab/tasks/main.yml b/_support/terraform/roles/gitlab/tasks/main.yml new file mode 100644 index 000000000..6dce64975 --- /dev/null +++ b/_support/terraform/roles/gitlab/tasks/main.yml @@ -0,0 +1,15 @@ +- name: /etc/gitlab/gitlab.rb + template: + src: gitlab-gitlab.rb.j2 + dest: /etc/gitlab/gitlab.rb + notify: + - gitlab-ctl reconfigure + - gitlab-ctl restart + - wait gitlab + - verify gitaly configuration + - verify gitlab-shell + +- name: Set Grafana password + command: + cmd: gitlab-ctl set-grafana-password + stdin: "{{ grafana_password }}\n{{ grafana_password }}\n" diff --git a/_support/terraform/roles/gitlab/templates/gitlab-gitlab.rb.j2 b/_support/terraform/roles/gitlab/templates/gitlab-gitlab.rb.j2 new file mode 100644 index 000000000..814e81e7d --- /dev/null +++ b/_support/terraform/roles/gitlab/templates/gitlab-gitlab.rb.j2 @@ -0,0 +1,37 @@ +external_url 'http://{{ groups['gitlabs'][0] }}' + +gitaly['enable'] = false + +git_data_dirs({ + "default" => { + "gitaly_address" => "tcp://{{ groups['loadbalancers'][0] }}:2305", + "gitaly_token" => '{{ praefect_external_token }}' + } +}) + +gitlab_shell['secret_token'] = '{{ gitlab_shell_secret_token }}' + +prometheus['scrape_configs'] = [ + { + 'job_name' => 'praefect', + 'static_configs' => [ + 'targets' => [ +{% for host in groups['praefects'] %} + '{{ hostvars[host]['internal'] }}:9652', # praefect-{{ loop.index }} +{% endfor %} + ] + ] + }, + { + 'job_name' => 'praefect-gitaly', + 'static_configs' => [ + 'targets' => [ +{% for host in groups['gitalies'] %} + '{{ hostvars[host]['internal'] }}:9236', # gitaly-{{ loop.index }} +{% endfor %} + ] + ] + } +] + +grafana['disable_login_form'] = false |