diff --git a/Vagrantfile b/Vagrantfile index f820b40..b16a97c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -29,8 +29,10 @@ Vagrant.configure("2") do |config| config.vm.provision "ansible" do |ansible| ansible.compatibility_mode = "2.0" ansible.verbose = "vv" + ansible.inventory_path = "playbooks/vagrant-inventory" + ansible.limit = "host, local" ansible.playbook = "playbooks/vagrant-dev.yml" end config.vm.post_up_message = $post_msg -end +end \ No newline at end of file diff --git a/acid/features/zuul_manager/tests/static/host_key.pub b/acid/features/zuul_manager/tests/static/host_key.pub index c252d4e..a817005 100644 --- a/acid/features/zuul_manager/tests/static/host_key.pub +++ b/acid/features/zuul_manager/tests/static/host_key.pub @@ -1 +1,2 @@ 10.10.10.5 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPaUGUDik0UGU/YUqD+k9Y7ztMCALoVsDkz89ijaCKxN +10.100.0.150 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPaUGUDik0UGU/YUqD+k9Y7ztMCALoVsDkz89ijaCKxN diff --git a/playbooks/ansible.cfg b/playbooks/ansible.cfg deleted file mode 100644 index 1eba39a..0000000 --- a/playbooks/ansible.cfg +++ /dev/null @@ -1,17 +0,0 @@ -# config file for ansible -- https://ansible.com/ -# =============================================== - -# nearly all parameters can be overridden in ansible-playbook -# or with command line flags. ansible will read ANSIBLE_CONFIG, -# ansible.cfg in the current working directory, .ansible.cfg in -# the home directory or /etc/ansible/ansible.cfg, whichever it -# finds first - -[defaults] -inventory = ./vagrant-inventory.yml -roles_path = /home/vagrant/.ansible/roles -remote_user = vagrant -executable = /bin/bash -private_key_file = /home/vagrant/.ssh/id_rsa -nocows = 1 -retry_files_enabled = False diff --git a/playbooks/install-zuul.yml b/playbooks/install-zuul.yml deleted file mode 100644 index c9488ed..0000000 --- a/playbooks/install-zuul.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- -- name: Install Zuul - hosts: vagrant - roles: - - openstack.zuul - tasks: - - set_fact: - zuul_ssh_dir: "/var/lib/zuul/.ssh" - gerrit_ssh_dir: "/home/vagrant/gerrit/.ssh" - - - name: Create zuul/.ssh directory - become: yes - file: - path: "{{ zuul_ssh_dir }}" - recurse: yes - state: directory - owner: zuul - - - name: Copy ssh keys to zuul dir - become: yes - shell: | - set -e - set -x - cp {{ gerrit_ssh_dir }}/admin_id_rsa id_rsa - chmod 600 id_rsa - chown zuul:zuul id_rsa - args: - chdir: "{{ zuul_ssh_dir }}" - - - name: Change mode and owner of zuul/id_rsa file - become: yes - file: - path: "{{ zuul_ssh_dir }}/id_rsa" - mode: u+r - owner: zuul - - - name: Create known_hosts file - become: yes - file: - path: "{{ zuul_ssh_dir }}/known_hosts" - mode: u+rw,g+r - owner: zuul - state: touch - - - name: restart Zuul services - become: yes - service: - name: "{{ item }}" - state: restarted - with_items: - - zuul-scheduler - - zuul-merger - - zuul-web diff --git a/playbooks/inventory.yml b/playbooks/inventory.yml index 4eda43a..6630d00 100644 --- a/playbooks/inventory.yml +++ b/playbooks/inventory.yml @@ -1,7 +1,17 @@ --- all: hosts: + gerrit-server: + ansible_host: 10.10.10.5 + ansible_port: 22 + ansible_user: vagrant + ansible_ssh_private_key_file: '/home/dariusz/.vagrant.d/insecure_private_key' + zuul-server: + ansible_host: 10.10.10.5 + ansible_port: 22 + ansible_user: vagrant + ansible_ssh_private_key_file: '/home/dariusz/.vagrant.d/insecure_private_key' acid-server: # Where to deploy ACID dashboard ansible_host: 10.100.0.1 - ansible_user: "ubuntu" + ansible_user: "ubuntu" \ No newline at end of file diff --git a/playbooks/roles/install-docker/tasks/main.yml b/playbooks/roles/install-docker/tasks/main.yml new file mode 100644 index 0000000..637868f --- /dev/null +++ b/playbooks/roles/install-docker/tasks/main.yml @@ -0,0 +1,78 @@ +--- +- name: "Create directory: /etc/docker" + become: yes + file: + path: "/etc/docker" + state: directory + mode: a+rwx + +- name: Copy daemon.json file + become: yes + template: + src: "daemon.json.j2" + dest: "/etc/docker/daemon.json" + +- name: Add dockers official GPG key + become: yes + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + +- name: Verify that key has a fingerprint + apt_key: + id: 0EBFCD88 + state: present + +- name: Set up repository + become: yes + apt_repository: + repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable" + state: present + update_cache: yes + +- name: Update packages + become: yes + apt: + update_cache: yes + +- name: Install docker + become: yes + apt: + name: docker-ce + state: present + update_cache: yes + +- name: Add user to docker group + become: yes + user: + name: "{{ ansible_user }}" + group: docker + append: yes + +- name: Install docker-compose + become: yes + apt: + name: docker-compose + state: present + update-cache: yes + +- name: Install pip2 + become: yes + apt: + name: python-pip + state: present + update_cache: yes + +- name: Install docker for docker module + become: yes + pip: + name: docker + +- name: Verify docker installation + shell: | + set -e + set -x + docker --version + docker-compose --version + args: + executable: /bin/bash \ No newline at end of file diff --git a/playbooks/roles/provision-dev/templates/daemon.json.j2 b/playbooks/roles/install-docker/templates/daemon.json.j2 similarity index 100% rename from playbooks/roles/provision-dev/templates/daemon.json.j2 rename to playbooks/roles/install-docker/templates/daemon.json.j2 diff --git a/playbooks/roles/provision-dev/vars/main.yml b/playbooks/roles/install-docker/vars/main.yml similarity index 100% rename from playbooks/roles/provision-dev/vars/main.yml rename to playbooks/roles/install-docker/vars/main.yml diff --git a/playbooks/roles/run-zuul/files/zuul.sql b/playbooks/roles/pre-zuul/files/zuul.sql similarity index 100% rename from playbooks/roles/run-zuul/files/zuul.sql rename to playbooks/roles/pre-zuul/files/zuul.sql diff --git a/playbooks/roles/run-zuul/tasks/gearman.yml b/playbooks/roles/pre-zuul/tasks/gearman.yml similarity index 100% rename from playbooks/roles/run-zuul/tasks/gearman.yml rename to playbooks/roles/pre-zuul/tasks/gearman.yml diff --git a/playbooks/roles/run-zuul/tasks/history-db.yml b/playbooks/roles/pre-zuul/tasks/history-db.yml similarity index 69% rename from playbooks/roles/run-zuul/tasks/history-db.yml rename to playbooks/roles/pre-zuul/tasks/history-db.yml index 43a94cf..9d13f9c 100644 --- a/playbooks/roles/run-zuul/tasks/history-db.yml +++ b/playbooks/roles/pre-zuul/tasks/history-db.yml @@ -1,17 +1,14 @@ --- - name: Run mariadb container become: yes - shell: | - set -e - set -x - docker run -d \ - -p 3306:3306 \ - --restart always \ - --name {{ zuul.history_db.name }} \ - -e MYSQL_ROOT_PASSWORD={{ zuul.history_db.pass }} \ - mariadb:10.3 - args: - executable: /bin/bash + docker_container: + name: "{{ zuul.history_db.name }}" + published_ports: + - 3306:3306 + env: + MYSQL_ROOT_PASSWORD: "{{ zuul.history_db.pass }}" + image: "mariadb:10.3" + restart_policy: always - name: Wait until MariaDB comes up (naive) pause: diff --git a/playbooks/roles/pre-zuul/tasks/main.yml b/playbooks/roles/pre-zuul/tasks/main.yml new file mode 100644 index 0000000..068359b --- /dev/null +++ b/playbooks/roles/pre-zuul/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: "Create directory for zuul" + file: + path: "{{ zuul.home }}" + state: directory + mode: a+rwx + recurse: true + +- include_tasks: history-db.yml +- include_tasks: zookeeper.yml +- include_tasks: gearman.yml \ No newline at end of file diff --git a/playbooks/roles/pre-zuul/tasks/zookeeper.yml b/playbooks/roles/pre-zuul/tasks/zookeeper.yml new file mode 100644 index 0000000..f36bb34 --- /dev/null +++ b/playbooks/roles/pre-zuul/tasks/zookeeper.yml @@ -0,0 +1,11 @@ +--- +- name: Run mariadb container + become: yes + docker_container: + name: zuul_zoo + published_ports: + - 2181:2181 + - 2888:2888 + - 3888:3888 + image: "zookeeper:3.4" + restart_policy: always diff --git a/playbooks/roles/pre-zuul/vars/main.yml b/playbooks/roles/pre-zuul/vars/main.yml new file mode 100644 index 0000000..6b2bbc2 --- /dev/null +++ b/playbooks/roles/pre-zuul/vars/main.yml @@ -0,0 +1,9 @@ +zuul: + home: "/home/{{ ansible_user }}/zuul" + history_db: + name: zuul_db + user: root + pass: root + # migrate example fixtures + # or start with empty database + migrate: true \ No newline at end of file diff --git a/playbooks/roles/provision-dev/tasks/main.yml b/playbooks/roles/provision-dev/tasks/main.yml index b39a9bb..82f2c43 100644 --- a/playbooks/roles/provision-dev/tasks/main.yml +++ b/playbooks/roles/provision-dev/tasks/main.yml @@ -1,100 +1,4 @@ --- -- name: Install distutils packages - become: yes - apt: - name: "{{ item }}" - state: present - update_cache: yes - with_items: - - apt-transport-https - - ca-certificates - - curl - - vim - - software-properties-common - - python3-pip - - python-pip - - python3.6 - - libre2-dev - - ansible - - nodejs - - npm - - apache2 - - bubblewrap - -- name: "Create directory: {{ item }}" - file: - path: "{{ item }}" - state: directory - mode: a+rwx - recurse: true - with_items: - - "{{ zuul.home }}" - - "{{ gerrit.home }}" - -- name: Create ssh key and add to authorized_key for vagrant user - shell: | - set -e - set -x - yes | ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa - cat ~/.ssh/id_rsa.pub | tee --append ~/.ssh/authorized_keys - chmod 700 ~/.ssh - chmod 600 ~/.ssh/id_rsa ~/.ssh/authorized_keys - args: - executable: /bin/bash - -- name: "Create directory: /etc/docker" - become: yes - file: - path: "/etc/docker" - state: directory - mode: a+rwx - -- name: Copy daemon.json file - become: yes - template: - src: "daemon.json.j2" - dest: "/etc/docker/daemon.json" - -- name: Install docker-ce - shell: | - set -e - set -x - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo apt-key fingerprint 0EBFCD88 - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt update - sudo apt install -y docker-ce - retry: 3 - args: - executable: /bin/bash - -- name: Install docker-compose - shell: | - set -e - set -x - sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - retry: 3 - args: - executable: /bin/bash - -- name: Add user to docker group - shell: | - set -e - set -x - sudo usermod -aG docker $USER - args: - executable: /bin/bash - -- name: Verify docker installation - shell: | - set -e - set -x - docker --version - docker-compose --version - args: - executable: /bin/bash - - name: Disable ssh Strict Host Key Checking become: yes lineinfile: @@ -102,17 +6,6 @@ regexp: "StrictHostKeyChecking" line: " StrictHostKeyChecking no" -- name: Generate language locales to suppress Perl warnings - become: yes - shell: | - set -e - set -x - locale-gen en_US en_US.UTF-8 pl_PL.UTF-8 - -- name: Set VIM as default editor - become: yes - shell: update-alternatives --set editor /usr/bin/vim.basic - - name: Copy host public key become: yes copy: diff --git a/playbooks/roles/run-zuul/tasks/config.yml b/playbooks/roles/provision-zuul/tasks/main.yml similarity index 68% rename from playbooks/roles/run-zuul/tasks/config.yml rename to playbooks/roles/provision-zuul/tasks/main.yml index 4d9355c..300f64e 100644 --- a/playbooks/roles/run-zuul/tasks/config.yml +++ b/playbooks/roles/provision-zuul/tasks/main.yml @@ -1,13 +1,17 @@ --- - set_fact: - galaxy_path: /home/vagrant/.ansible/roles + galaxy_path: ~/.ansible/roles -- name: Create ~/.ansible/roles directory - file: - path: "{{ galaxy_path }}" - state: directory - recurse: true - owner: vagrant +- name: Check if zuul role exist + stat: + path: "{{ galaxy_path }}/openstack.zuul" + register: openstack_role + +- name: Delete openstack zuul role if it exist + file: + state: absent + path: "{{ galaxy_path }}/openstack.zuul" + when: openstack_role.stat.exists == True - name: Install zuul role from ansible galaxy shell: | @@ -23,13 +27,11 @@ dest: "{{ galaxy_path }}/openstack.zuul/templates/etc/zuul/zuul.conf" - name: Deploy main.yaml file - become: yes template: src: main.yaml.j2 dest: "{{ galaxy_path }}/openstack.zuul/templates/etc/zuul/main.yaml" - name: Change deploy method from PIP to GIT - become: yes lineinfile: path: "{{ galaxy_path }}/openstack.zuul/defaults/main.yaml" regexp: "^zuul_install_method: pip" diff --git a/playbooks/roles/run-zuul/templates/main.yaml.j2 b/playbooks/roles/provision-zuul/templates/main.yaml.j2 similarity index 100% rename from playbooks/roles/run-zuul/templates/main.yaml.j2 rename to playbooks/roles/provision-zuul/templates/main.yaml.j2 diff --git a/playbooks/roles/run-zuul/templates/zuul.conf.j2 b/playbooks/roles/provision-zuul/templates/zuul.conf.j2 similarity index 100% rename from playbooks/roles/run-zuul/templates/zuul.conf.j2 rename to playbooks/roles/provision-zuul/templates/zuul.conf.j2 diff --git a/playbooks/roles/run-gerrit/tasks/main.yml b/playbooks/roles/run-gerrit/tasks/main.yml index 135455f..67ebc85 100644 --- a/playbooks/roles/run-gerrit/tasks/main.yml +++ b/playbooks/roles/run-gerrit/tasks/main.yml @@ -1,4 +1,11 @@ --- +- name: "Create gerrit directory" + file: + path: "{{ gerrit.home }}" + state: directory + mode: a+rwx + recurse: true + - name: Create directories for Gerrit file: path: "{{ gerrit.home }}/{{ item }}" @@ -48,36 +55,12 @@ - db - index - git - when: gerrit.from_scratch == false - -- name: Initialize Gerrit container - become: yes - shell: | - set -e - set -x - docker-compose up - args: - executable: /bin/bash - chdir: "{{ gerrit.home }}" - when: gerrit.from_scratch == true - -- name: Remove init entrypoint for Gerrit - # Entrypoint is used for running Gerrit from scratch. - # Either way it has to be removed at this point. - lineinfile: - path: "{{ gerrit.home }}/docker-compose.yaml" - state: absent - regexp: "entrypoint" -- name: Run Gerrit container +- name: Run gerrit container become: yes - shell: | - set -e - set -x - docker-compose up -d - args: - executable: /bin/bash - chdir: "{{ gerrit.home }}" + docker_service: + project_src: "{{ gerrit.home }}" + state: present - name: Wait until gerrit comes up wait_for: diff --git a/playbooks/roles/run-gerrit/templates/gerrit-compose.yaml.j2 b/playbooks/roles/run-gerrit/templates/gerrit-compose.yaml.j2 index 2b67470..9e70ac6 100644 --- a/playbooks/roles/run-gerrit/templates/gerrit-compose.yaml.j2 +++ b/playbooks/roles/run-gerrit/templates/gerrit-compose.yaml.j2 @@ -3,7 +3,6 @@ version: '3' services: gerrit: image: gerritcodereview/gerrit - entrypoint: java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit volumes: - {{ gerrit.home }}/etc:/var/gerrit/etc - {{ gerrit.home }}/git:/var/gerrit/git diff --git a/playbooks/roles/run-gerrit/templates/gerrit.config.j2 b/playbooks/roles/run-gerrit/templates/gerrit.config.j2 index 428bf96..b69d775 100644 --- a/playbooks/roles/run-gerrit/templates/gerrit.config.j2 +++ b/playbooks/roles/run-gerrit/templates/gerrit.config.j2 @@ -1,6 +1,6 @@ [gerrit] basePath = git - canonicalWebUrl = http://{{ host_ip }}:8080/ + canonicalWebUrl = http://{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:8080/ [database] type = H2 diff --git a/playbooks/roles/run-gerrit/vars/main.yml b/playbooks/roles/run-gerrit/vars/main.yml index 4d3b96b..e501c6c 100644 --- a/playbooks/roles/run-gerrit/vars/main.yml +++ b/playbooks/roles/run-gerrit/vars/main.yml @@ -3,4 +3,7 @@ templates: gerrit_compose: subnet: "192.168.2.5/24" +gerrit: + home: "/home/{{ ansible_user }}/gerrit" + from_scratch: false diff --git a/playbooks/roles/run-zuul/files/gerrit_admin_id_rsa b/playbooks/roles/run-zuul/files/gerrit_admin_id_rsa new file mode 100644 index 0000000..4d7eaee --- /dev/null +++ b/playbooks/roles/run-zuul/files/gerrit_admin_id_rsa @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAwQll2g6e+JlWXXX0qy3E4uMUAIccv7uPSvE0XZH52KBfrs57 +BOJR//fEIazgsL5FCUExA29dOVIIP5O7GHXneQ4mGjYmQgzlRvrXVzLT5ihH0O5B +cLHVs0GGKtGNfzOFgJxM/j33WvLoC3QYnqsVuko4TMSjcfRV0L/kt4x1WpXyojfD +nohsI5jCcn6JbafhqzAIk1m6L+3gwd00WPUfpFLEXUfN/hgrYsEUSNi+SWcGHSCm +TpRm/vHPx8J9P5/bZjHmFs+VAIE1EWhC+AI4HTON7WrMKFM8TUUe9KflImFEYt0b +8tlRk4oZ1iKZRH3LmhlaURm+L1A6e4p75X9l9wIDAQABAoIBAHv6ODMLTuhlOwW9 +m01RkPETXKZWII23vXkpXzN1bJzHq4xOys3BOV8HVy01pf19xkMCXqNRI/OLjwae +L/yuxOKHxsrw2jNzqtGiiylS2KsqVa2HR/pEDPca7zuS6Ki4g1ati/mB/NqpxYSN +pL5LLSI/RtdvN3YZsf/nLtL/3+Mz6ynAipaHraNllDwO5Q6kCGqS4xJYdm5m01h7 +3J01QplYe/VvgmyvSCsRQOgQxn+8R4yXpmCsvFSzKKHAlzkNwV9MI6G2aWCeyQos +JAHYibcqGfVC4s6xe+MecEm4UlM50gnn+4T/2F5ZNXCxYfUk1+4Z8Kgbws5QBt+/ +Zh+RIMECgYEA5rS5sUkoUCTdqDW+zMThgjglcad/7H+WP7Kj6phcfP4cUVRnF2U5 +aGvgXKTX2ggZqdGc/Q+rcn/NDMRcEUXN0COpqyR3B45GEyFq85oliKhBajsEPKMt +wtclfADTNrq/zG5HyGPNQTejw8r/BtAi+xNUKtgTycLW/ud3sD+QKFcCgYEA1jNm +xncnUGXKQVEWKxzAzrLgd6PMqVfgjlyATTf7VIJlGl1kKNwRCWq1RGuOzQfaNpZE +h44j6h41+NPwvwjeHUGijckEnpp/008QK130v6lG6qH9/1diGM7HoGveY1GFhRgl +Hapus1UrYxP1gjlwZKxxfd7GCfdHhE8ek8XCq2ECgYEAx9VdTzoeKCV2tiAvr/EN +oJz/mg3LWdA+Fdin8SmeW0pEvxHL5lDwxAlFIxpKOfpwOE9vmye6iwg2Vcu0L+X1 +20c4zRxd2fabrjBxEqa/wjpzxw9toRR7K9zuBBY23Z4vSmVv2hzQiqAmQw8Pjhg1 +ZKOecSoPIeGaFtvqKYk1VisCgYBfr36N0dSCGbaMDwj0IVgP/eBAEa/vRg5OCgxW +cleXnNhFOsrvZb9GkaB/+/xCoutbzyy10U1B3FUH3sWA0RlHwHY5GD80CphncL4s +YUBgDeJcFhk843Ay3MxYYVdqzpPyrKKH6gahnb5P+C6ICdinYFEihU26Tfhopl9m +a8VWgQKBgQDl7m6dMutpKLMLnHio/5idAyiq09arYCgSJykVfwXbqA+vTiYXXbo2 +8d0nv9sz+ez+fF3qZ5vQdnD61AVmbNaqFH4sJnlLMxt5wv78EvAwZaWOjW89HGaC +45MqVcelorAwvlfvdoM4LKD1IMbJBqUfzz0P2NFV+vrtxex+87D+Xg== +-----END RSA PRIVATE KEY----- diff --git a/playbooks/roles/run-zuul/tasks/main.yml b/playbooks/roles/run-zuul/tasks/main.yml index 23e1608..ee895bf 100644 --- a/playbooks/roles/run-zuul/tasks/main.yml +++ b/playbooks/roles/run-zuul/tasks/main.yml @@ -1,17 +1,68 @@ --- -- include_tasks: history-db.yml -- include_tasks: zookeeper.yml -- include_tasks: gearman.yml -- include_tasks: config.yml +- name: Install pip3 for openstack role + become: yes + apt: + name: python3-pip + state: present + update_cache: yes + +- name: Check if src folder exists + stat: + path: "~/src" + register: openstack_zuul_src + +- name: Delete openstack zuul role if it exist + file: + state: absent + path: "~/src" + when: openstack_zuul_src.stat.exists == True - name: Run ansible-role-zuul - shell: | - set -e - set -x - ansible-playbook -vv -i vagrant-inventory.yml install-zuul.yml - args: - chdir: /opt/app/playbooks - executable: /bin/bash + include_role: + name: openstack.zuul + +- set_fact: + zuul_ssh_dir: "/var/lib/zuul/.ssh" + +- name: Create zuul/.ssh directory + become: yes + file: + path: "{{ zuul_ssh_dir }}" + recurse: yes + state: directory + owner: zuul + +- name: Copy Gerrit host ssh key + become: yes + copy: + src: gerrit_admin_id_rsa + dest: "{{ zuul_ssh_dir }}/id_rsa" + +- name: Set permissions for gerrit ssh key + become: yes + file: + path: "{{ zuul_ssh_dir }}/id_rsa" + owner: zuul + group: zuul + mode: 0600 + +- name: Create known_hosts file + become: yes + file: + path: "{{ zuul_ssh_dir }}/known_hosts" + mode: u+rw,g+r + owner: zuul + state: touch + +- name: restart Zuul services + become: yes + service: + name: "{{ item }}" + state: restarted + with_items: + - zuul-scheduler + - zuul-merger + - zuul-web - include_tasks: zuul-scheduler-service.yml - include_tasks: website.yml diff --git a/playbooks/roles/run-zuul/tasks/website.yml b/playbooks/roles/run-zuul/tasks/website.yml index 3dd1a50..db325b0 100644 --- a/playbooks/roles/run-zuul/tasks/website.yml +++ b/playbooks/roles/run-zuul/tasks/website.yml @@ -7,6 +7,16 @@ owner: zuul mode: u+rwx,g+rwx,o+rw +- name: Install npm and apache2 + become: yes + apt: + name: "{{ item }}" + state: present + update_cache: yes + with_items: + - npm + - apache2 + - name: Install YARN npm package become: yes npm: @@ -17,9 +27,6 @@ - webpack@^4.4.0 - webpack-cli@^2.0.11 -- set_fact: - web_src: /home/vagrant/src/git.openstack.org/openstack-infra/zuul - - name: Install NPM Dependencies shell: | set -e @@ -32,7 +39,7 @@ shell: | set -e set -x - npm run build:dist -- --define ZUUL_API_URL="'http://10.10.10.5'" + npm run build -- --define ZUUL_API_URL="'{{ zuul_api_url }}'" args: chdir: "{{ web_src }}" diff --git a/playbooks/roles/run-zuul/tasks/zookeeper.yml b/playbooks/roles/run-zuul/tasks/zookeeper.yml deleted file mode 100644 index b9bcab8..0000000 --- a/playbooks/roles/run-zuul/tasks/zookeeper.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Run zookeeper container - become: yes - shell: | - set -e - set -x - docker run -d -p 2181:2181 -p 2888:2888 -p 3888:3888 \ - --restart always \ - --name zuul_zoo \ - zookeeper:3.4 - args: - executable: /bin/bash diff --git a/playbooks/roles/run-zuul/vars/main.yml b/playbooks/roles/run-zuul/vars/main.yml new file mode 100644 index 0000000..ffb82f2 --- /dev/null +++ b/playbooks/roles/run-zuul/vars/main.yml @@ -0,0 +1,2 @@ +web_src: "/home/{{ ansible_user }}/src/git.openstack.org/openstack-infra/zuul/web" +zuul_api_url: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}" diff --git a/playbooks/vagrant-dev.yml b/playbooks/vagrant-dev.yml index dd026b1..e654157 100644 --- a/playbooks/vagrant-dev.yml +++ b/playbooks/vagrant-dev.yml @@ -8,24 +8,7 @@ # Usage: # 1. install Vagrant and VirtualBox # 2. run command: vagrant up -- hosts: all - vars: - host_ip: "{{ ansible_enp0s8.ipv4.address }}" - gerrit: - baseurl: "http://{{ ansible_enp0s8.ipv4.address }}/" - home: "/home/vagrant/gerrit" - # should we import database fixtures - # or initialize empty gerrit from scratch - from_scratch: false - zuul: - home: "/home/vagrant/zuul" - history_db: - name: zuul_db - user: root - pass: root - # migrate example fixtures - # or start with empty database - migrate: true +- hosts: gerrit-server gather_facts: no pre_tasks: # Ubuntu/bionic64 ships without python2 which causes Ansible to fail on gather_facts @@ -35,14 +18,24 @@ - action: setup roles: - provision-dev + - install-docker - run-gerrit + +- hosts: localhost + connection: local + roles: + - provision-zuul + +- hosts: zuul-server + gather_facts: no + pre_tasks: + # Ubuntu/bionic64 ships without python2 which causes Ansible to fail on gather_facts + - name: Install python2 for Ansible + raw: test -e /usr/bin/python || (sudo apt -y update && sudo apt install -y python-minimal) + # "Setup" action will gather facts after python2 has been installed + - action: setup + roles: + - provision-dev + - install-docker + - pre-zuul - run-zuul - tasks: - - name: Set environments for GIT - # git user.name and user.email comes from Gerrit configuration. - shell: | - set -e - set -x - echo "export GIT_SSH_COMMAND='ssh -i {{ gerrit.home }}/.ssh/admin_id_rsa'" >> /home/vagrant/.bashrc - git config --global user.name "Administrator" - git config --global user.email "admin@example.com" diff --git a/playbooks/vagrant-inventory b/playbooks/vagrant-inventory new file mode 100644 index 0000000..a45c3fd --- /dev/null +++ b/playbooks/vagrant-inventory @@ -0,0 +1,11 @@ +host ansible_host=10.10.10.5 ansible_port=22 ansible_user='vagrant' ansible_ssh_private_key_file='/home/dariusz/.vagrant.d/insecure_private_key' +local ansible_connection=local + +[gerrit-server] +host + +[zuul-server] +host + +[localhost] +local diff --git a/playbooks/vagrant-inventory.yml b/playbooks/vagrant-inventory.yml deleted file mode 100644 index 42e22c0..0000000 --- a/playbooks/vagrant-inventory.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -all: - hosts: - dev: - ansible_host: 127.0.0.1 - ansible_connection: local - children: - vagrant: - hosts: - dev: