diff --git a/roles/gitlab/meta/main.yml b/roles/gitlab/meta/main.yml deleted file mode 100644 index 13750fe..0000000 --- a/roles/gitlab/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -dependencies: -- role: redis -- role: yarn diff --git a/roles/gitlab/tasks/main.yml b/roles/gitlab/tasks/main.yml index 882e802..1c16b6f 100644 --- a/roles/gitlab/tasks/main.yml +++ b/roles/gitlab/tasks/main.yml @@ -1,258 +1,267 @@ - name: install dependencies apt: # I think many of these dependencies are only needed to compile Ruby from source, which we're not doing; # but just to be sure we'll install them anyway according to the official docs. name: [build-essential, zlib1g-dev, libyaml-dev, libssl-dev, libgdbm-dev, libre2-dev, libreadline-dev, libncurses5-dev, libffi-dev, curl, openssh-server, checkinstall, libxml2-dev, libxslt-dev, libcurl4-openssl-dev, libicu-dev, logrotate, rsync, python-docutils, pkg-config, cmake, runit] state: present - name: install Ruby apt: name: [ruby2.5, ruby2.5-dev, ruby-bundler] state: present # TODO this isn't correct for our production server - name: pre-configure postfix debconf: name: postfix question: postfix/main_mailer_type value: "Internet Site" vtype: select - name: install postfix apt: name: postfix state: present - name: install Go apt: name: golang-1.10 state: present - name: install NodeJS apt: name: nodejs state: present +- import_role: + name: yarn + +- import_role: + name: redis + +- name: run handlers to restart redis + meta: flush_handlers + - name: install PostgreSQL apt: name: [postgresql, postgresql-client, libpq-dev, postgresql-contrib, python-psycopg2] state: present - name: create PostgreSQL user become_user: postgres postgresql_user: name: git role_attr_flags: CREATEDB - name: enable trgm PostgreSQL extension become_user: postgres postgresql_ext: db: template1 name: pg_trgm state: present - name: create PostgreSQL database become_user: postgres postgresql_db: name: gitlab_production state: present owner: git - name: create system user for GitLab user: name: git comment: GitLab,,, shell: /bin/bash password: '!' append: yes groups: redis - name: create /srv/gitlab file: path: /srv/gitlab state: directory owner: git group: git - name: clone gitlab code become_user: git git: #repo: https://gitlab.com/gitlab-org/gitlab-ce.git repo: /vagrant/gitlab-ce.git version: 11-9-stable dest: /srv/gitlab/gitlab - name: set permissions on log directory file: path: /srv/gitlab/gitlab/log state: directory owner: git group: git mode: 0755 - name: create public uploads directory file: path: /srv/gitlab/gitlab/public/uploads state: directory owner: git group: git mode: 0700 - name: create and fix permissions on other GitLab directories become_user: git file: path: /srv/gitlab/gitlab/{{item}} state: directory owner: git group: git mode: 0775 with_items: - tmp - tmp/pids - tmp/sockets - builds - shared/artifacts - shared/pages - name: install configuration files copy: src: "{{item}}" dest: /srv/gitlab/gitlab/config/{{item}} owner: git group: git with_items: - gitlab.yml - unicorn.rb - resque.yml - database.yml - name: install secrets.yml configuration copy: src: secrets.yml dest: /srv/gitlab/gitlab/config/secrets.yml mode: 0600 owner: git group: git - name: copy rack_attack configuration copy: remote_src: yes src: /srv/gitlab/gitlab/config/initializers/rack_attack.rb.example dest: /srv/gitlab/gitlab/config/initializers/rack_attack.rb owner: git group: git - name: configure git become_user: git git_config: scope: global name: "{{item.key}}" value: "{{item.value}}" loop: # 'autocrlf' is needed for the web editor - { key: core.autocrlf, value: input } # Disable 'git gc --auto' because GitLab already runs 'git gc' when needed - { key: gc.auto, value: 0 } # Enable packfile bitmaps - { key: repack.writeBitmaps, value: "true" } # Enable push options - { key: receive.advertisePushOptions, value: "true" } - name: install gems become_user: git bundler: chdir: /srv/gitlab/gitlab deployment_mode: yes extra_args: -j3 --without development test mysql aws kerberos environment: MAKEFLAGS: -j4 # This doesn't apply to Ansible tasks, it's just for interactive use. # We still need an explicit 'environment:' to get GOROOT and PATH # in tasks. - name: add Go to the user PATH become_user: git blockinfile: path: /home/git/.bashrc marker: "# {mark} Ansible-managed: make sure Go works" block: | export GOROOT="/usr/lib/go-1.10" export PATH="$GOROOT/bin/:$PATH" - name: install GitLab Shell become_user: git command: bundle exec rake --trace gitlab:shell:install REDIS_URL=unix:/var/run/redis/redis-server.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true args: chdir: /srv/gitlab/gitlab creates: /srv/gitlab/gitlab-shell environment: GOROOT: /usr/lib/go-1.10 PATH: "/usr/lib/go-1.10/bin/:{{ansible_env.PATH}}" - name: install gitlab-workhorse become_user: git command: bundle exec rake "gitlab:workhorse:install[/srv/gitlab/gitlab-workhorse]" RAILS_ENV=production args: chdir: /srv/gitlab/gitlab creates: /srv/gitlab/gitlab-workhorse environment: GOROOT: /usr/lib/go-1.10 PATH: "/usr/lib/go-1.10/bin/:{{ansible_env.PATH}}" - name: get required gitlab-pages version become_user: git slurp: src: /srv/gitlab/gitlab/GITLAB_PAGES_VERSION register: pages_version - name: clone gitlab-pages code become_user: git git: repo: https://gitlab.com/gitlab-org/gitlab-pages.git version: "v{{pages_version['content'] | b64decode | trim}}" dest: /srv/gitlab/gitlab-pages - name: compile gitlab-pages become_user: git make: chdir: /srv/gitlab/gitlab-pages environment: GOROOT: /usr/lib/go-1.10 PATH: "/usr/lib/go-1.10/bin/:{{ansible_env.PATH}}" - name: install gitaly become_user: git command: bundle exec rake "gitlab:gitaly:install[/srv/gitlab/gitaly,/srv/gitlab/repositories]" RAILS_ENV=production args: chdir: /srv/gitlab/gitlab creates: /srv/gitlab/gitaly/gitaly environment: GOROOT: /usr/lib/go-1.10 PATH: "/usr/lib/go-1.10/bin/:{{ansible_env.PATH}}" MAKEFLAGS: -j4 - name: restrict gitaly socket access file: path: /srv/gitlab/gitlab/tmp/sockets/private state: directory owner: git group: git mode: 0700 - name: install gitaly configuration copy: src: gitaly-config.toml dest: /srv/gitlab/gitaly/config.toml owner: git group: git # super important: make sure we only run this once - name: initialize database become_user: git script: with-gitaly.sh bundle exec rake gitlab:setup RAILS_ENV=production force=yes args: chdir: /srv/gitlab/gitlab when: first_run|default(False)