Parcourir la source

fixed ansible project structure

Gleb Urvanov il y a 4 ans
Parent
commit
7664ee4b05

+ 11 - 6
devops/ansible/build-and-run-tests-single-node-playbook.yml

@@ -1,12 +1,17 @@
-- name: install dependencies
-  import_playbook: install-dependencies-playbook.yml
-
 - hosts: 127.0.0.1
   user: root
   become: yes
   become_method: sudo
+
   tasks:
+    - name: install dependencies
+      include_role:
+        name: install_dependencies
+
     - name: build node
-      include: build-image-tasklist.yml
-- name: run tests
-  import_playbook: run-tests-single-node-playbook.yml
+      include_role:
+        name: build_docker_image
+        
+    - name: run tests
+      include_role:
+        name: run_tests_single_node

+ 17 - 0
devops/ansible/build-and-run-tests-two-nodes-playbook.yml

@@ -0,0 +1,17 @@
+- hosts: 127.0.0.1
+  user: root
+  become: yes
+  become_method: sudo
+
+  tasks:
+    - name: install dependencies
+      include_role:
+        name: install_dependencies
+
+    - name: build node
+      include_role:
+        name: build_docker_image
+        
+    - name: run tests
+      include_role:
+        name: run_tests_two_nodes

+ 13 - 0
devops/ansible/build-image-playbook.yml

@@ -0,0 +1,13 @@
+- hosts: 127.0.0.1
+  user: root
+  become: yes
+  become_method: sudo
+
+  tasks:
+    - name: install dependencies
+      include_role:
+        name: install_dependencies
+
+    - name: build node
+      include_role:
+        name: build_docker_image

+ 0 - 41
devops/ansible/install-dependencies-playbook.yml

@@ -1,41 +0,0 @@
-- hosts: 127.0.0.1
-  user: root
-  become: yes
-  become_method: sudo
-  tasks:
-
-    - name: install pip on Debian
-      block:
-        - name: install pip using apt
-          apt: name=python-pip state=present
-      when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
-
-    - name: install pip on Mac
-      block:
-        - name: create temporary folder
-          file:
-            path: ../../.tmp
-            state: directory
-        - name: get pip installer using curl
-          get_url: 
-            url: https://bootstrap.pypa.io/get-pip.py
-            dest: ../../.tmp/get-pip.py
-        - name: install pip
-          shell: python ../../.tmp/get-pip.py
-      when: ansible_distribution == 'MacOSX'
-      always: 
-        - name: remove pip installer script
-          file: 
-            path: ../../.tmp/get-pip.py
-            state: absent
-
-    - name: install docker
-      pip: name=docker
-
-    - name: Install yarn with npm
-      npm:
-        name: yarn
-        global: yes
-
-    - name: Install docker compose
-      pip: name=docker-compose

+ 0 - 0
devops/ansible/build-image-tasklist.yml → devops/ansible/roles/build_docker_image/tasks/main.yml


+ 35 - 0
devops/ansible/roles/install_dependencies/tasks/main.yml

@@ -0,0 +1,35 @@
+- name: install pip on Debian
+  block:
+    - name: install pip using apt
+      apt: name=python-pip state=present
+  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
+
+- name: install pip on Mac
+  block:
+    - name: create temporary folder
+      file:
+        path: ../../.tmp
+        state: directory
+    - name: get pip installer using curl
+      get_url: 
+        url: https://bootstrap.pypa.io/get-pip.py
+        dest: ../../.tmp/get-pip.py
+    - name: install pip
+      shell: python ../../.tmp/get-pip.py
+  when: ansible_distribution == 'MacOSX'
+  always: 
+    - name: remove pip installer script
+      file: 
+        path: ../../.tmp/get-pip.py
+        state: absent
+
+- name: install docker
+  pip: name=docker
+
+- name: Install yarn with npm
+  npm:
+    name: yarn
+    global: yes
+
+- name: Install docker compose
+  pip: name=docker-compose

+ 22 - 0
devops/ansible/roles/run_tests_single_node/tasks/main.yml

@@ -0,0 +1,22 @@
+- name: run network
+  block:
+
+    - name: run docker container
+      docker_container:
+        name: "joystream-node-testing"
+        image: "joystream/node-testing"
+        ports:
+          - "9944:9944"
+        entrypoint: ./node --chain=chainspec.json --alice --validator --ws-external --rpc-cors=all
+        state: started
+
+    - name: execute network tests
+      shell: yarn debug >> ../../.tmp/tests.log
+      args:
+        chdir: ../../tests/network-tests/
+        
+  always:
+    - name: stop docker container
+      docker_container:
+        name: "joystream-node-testing"
+        state: absent

+ 18 - 0
devops/ansible/roles/run_tests_two_nodes/tasks/main.yml

@@ -0,0 +1,18 @@
+- name: run network
+  block:
+
+    - name: run two nodes containerized network
+      docker_compose:
+        project_src: ./
+        state: present
+
+    - name: execute network tests
+      shell: yarn test >> ../../.tmp/tests.log
+      args:
+        chdir: ../../tests/network-tests/
+        
+  always:
+    - name: stop containers
+      docker_compose:
+        project_src: ./
+        state: absent

+ 0 - 24
devops/ansible/run-tests-single-node-playbook.yml

@@ -1,24 +0,0 @@
-- hosts: 127.0.0.1
-  user: root
-  become: yes
-  become_method: sudo
-  tasks:
-    - name: run network
-      block:
-        - name: run docker container
-          docker_container:
-            name: "joystream-node-testing"
-            image: "joystream/node-testing"
-            ports:
-              - "9944:9944"
-            entrypoint: ./node --chain=chainspec.json --alice --validator --ws-external --rpc-cors=all
-            state: started
-        - name: execute network tests
-          shell: yarn debug >> ../../.tmp/tests.log
-          args:
-            chdir: ../../tests/network-tests/
-      always:
-        - name: stop docker container
-          docker_container:
-            name: "joystream-node-testing"
-            state: absent

+ 0 - 24
devops/ansible/run-tests-two-nodes-playbook.yml

@@ -1,24 +0,0 @@
-- name: install dependencies
-  import_playbook: install-dependencies-playbook.yml
-
-- hosts: 127.0.0.1
-  user: root
-  become: yes
-  become_method: sudo
-
-  tasks:
-    - name: run network
-      block:
-        - name: run two nodes containerized network
-          docker_compose:
-            project_src: ./
-            state: present
-        - name: execute network tests
-          shell: yarn test >> ../../.tmp/tests.log
-          args:
-            chdir: ../../tests/network-tests/
-      always:
-        - name: stop containers
-          docker_compose:
-            project_src: ./
-            state: absent