Разворачиваем Gitlab с помощью Ansible

Делаю
12.04.2019


$ mkdir ~/ansible-galaxy && cd ~/ansible-galaxy


$ vi Vagrantfile



VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.ssh.insert_key = false
  config.ssh.forward_agent = true

  config.vm.provision :hosts do |provisioner|

      provisioner.add_host '192.168.56.101', ['controller']

  end

  config.vm.define "controller" do |controller|
    controller.vm.box = 'ubuntu/bionic64'
    controller.vm.hostname = 'controller'

    controller.vm.network :private_network, ip: "192.168.56.101"
    controller.vm.network :forwarded_port, guest: 22, host: 10122, id: "ssh"

    controller.vm.provider :virtualbox do |v|
      v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
      v.customize ["modifyvm", :id, "--memory", 8192]
      v.customize ["modifyvm", :id, "--name", "controller"]
    end

    controller.vm.provision :shell, path: "install-ansible.sh"

  end

  config.vm.provision :shell, path: "update-ubuntu-packages.sh"

end


$ vi install-ansible.sh


#!/usr/bin/env bash

apt-add-repository -y ppa:ansible/ansible
apt update
apt install -y ansible


$ vi update-ubuntu-packages.sh


#!/usr/bin/env bash

apt update && apt upgrade -y


$ ssh-add ~/.vagrant.d/insecure_private_key
$ vagrant box update
$ vagrant up


$ vagrant ssh controller


$ sudo su  -
# adduser --disabled-password --gecos "" ansible
# usermod -aG sudo ansible
# passwd ansible

# vi /etc/ssh/sshd_config
PasswordAuthentication yes

# service sshd reload


# su - ansible

$ ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -q -N ""

$ ssh-copy-id [email protected]

// Проверка подключения без ввода пароля
$ ssh [email protected]
exit

$ cd ~
$ git clone --depth=1 https://github.com/marley-nodejs/Hands-On-DevOps-with-Ansible/


$ cd /home/ansible/Hands-On-DevOps-with-Ansible/infrastructure/


$ vi inventory


[gitlab-ce]
controller


$ vi ansible.cfg


[defaults]
remote_user = ansible
host_key_checking = false
inventory = inventory

[privilege_escalation]
become = True
become_method = sudo
become_user = root
becore_ask_pass = False


$ vi playbook.yaml
- hosts: gitlab-ce
  become: yes
  roles:
      - geerlingguy.gitlab


$ ansible-galaxy install geerlingguy.gitlab


$ ansible-playbook playbook.yaml -K


Остается подключиться:
http://192.168.56.101/