summaryrefslogtreecommitdiffstats
path: root/ansible
diff options
context:
space:
mode:
authorMichal Zegan <m.zegan@samsung.com>2019-05-22 17:53:00 +0200
committerSamuli Silvius <s.silvius@partner.samsung.com>2019-05-30 10:52:57 +0000
commita83ae84c589effcd690180347294ceaa677c2c7b (patch)
treece46dbcd3cb9d44603e60b74df1bde14e54c08c6 /ansible
parent7e5ddf0b3e0f23bf499b3311340253485d06fc33 (diff)
Modify rancher molecule tests to use dind
This change modifies molecule tests of rancher role to use prepare-docker-dind. Also: - it modifies prepare-common role to retrieve cluster_ip of the actual node in question, - it fixes the rancher role itself to work at all by removing auto_remove. It has been tested by running molecule converge. Change-Id: I7af4e9998feedd5f8fc3df8215e03c1b0485529c Issue-ID: OOM-1864 Signed-off-by: Michal Zegan <m.zegan@samsung.com>
Diffstat (limited to 'ansible')
-rw-r--r--ansible/roles/rancher/molecule/default/cleanup.yml14
-rw-r--r--ansible/roles/rancher/molecule/default/molecule.yml9
-rw-r--r--ansible/roles/rancher/molecule/default/playbook.yml2
-rw-r--r--ansible/roles/rancher/molecule/default/prepare.yml6
-rw-r--r--ansible/roles/rancher/tasks/rancher_agent.yml1
-rw-r--r--ansible/test/roles/prepare-common/tasks/main.yml33
6 files changed, 12 insertions, 53 deletions
diff --git a/ansible/roles/rancher/molecule/default/cleanup.yml b/ansible/roles/rancher/molecule/default/cleanup.yml
deleted file mode 100644
index d4bf4495..00000000
--- a/ansible/roles/rancher/molecule/default/cleanup.yml
+++ /dev/null
@@ -1,14 +0,0 @@
----
-- name: Cleanup host
- hosts: localhost
- roles:
- - role: cleanup-containers
- vars:
- container_list:
- - rancher-agent
- - rancher-server
- - role: cleanup-rancher
- vars:
- container_list_by_label:
- - { 'label':'io.rancher.project.name', 'value':'healthcheck'}
- - { 'label':'io.rancher.project.name', 'value':'kubernetes'}
diff --git a/ansible/roles/rancher/molecule/default/molecule.yml b/ansible/roles/rancher/molecule/default/molecule.yml
index b21325d4..eb7f8c19 100644
--- a/ansible/roles/rancher/molecule/default/molecule.yml
+++ b/ansible/roles/rancher/molecule/default/molecule.yml
@@ -13,8 +13,7 @@ platforms:
override_command: false
restart_policy: unless-stopped
volumes:
- - /var/run/docker.sock:/var/run/docker.sock
- - /var/lib/rancher:/var/lib/rancher:ro
+ - /var/lib/docker
groups:
- infrastructure
networks:
@@ -27,12 +26,14 @@ platforms:
override_command: false
restart_policy: unless-stopped
volumes:
- - /var/run/docker.sock:/var/run/docker.sock
- - /var/lib/rancher:/var/lib/rancher:ro
+ - /var/lib/docker
+ - /var/lib/rancher
+ - /var/lib/kubelet
groups:
- kubernetes
networks:
- name: rancher
+ purge_networks: true
provisioner:
name: ansible
diff --git a/ansible/roles/rancher/molecule/default/playbook.yml b/ansible/roles/rancher/molecule/default/playbook.yml
index e0ef086c..e4a7151e 100644
--- a/ansible/roles/rancher/molecule/default/playbook.yml
+++ b/ansible/roles/rancher/molecule/default/playbook.yml
@@ -2,7 +2,7 @@
- name: Converge rancher master
hosts: infrastructure
roles:
- - prepare-common # molecule specific role needed here to populate cluster_ip
+ - prepare-common
- role: rancher
vars:
mode: server
diff --git a/ansible/roles/rancher/molecule/default/prepare.yml b/ansible/roles/rancher/molecule/default/prepare.yml
index 90159c6c..d70cda43 100644
--- a/ansible/roles/rancher/molecule/default/prepare.yml
+++ b/ansible/roles/rancher/molecule/default/prepare.yml
@@ -1,5 +1,5 @@
---
-- name: Prepare kube nodes
- hosts: kubernetes
+- name: Prepare hosts
+ hosts: all
roles:
- - prepare-docker
+ - prepare-docker-dind
diff --git a/ansible/roles/rancher/tasks/rancher_agent.yml b/ansible/roles/rancher/tasks/rancher_agent.yml
index 091503c7..73d9a642 100644
--- a/ansible/roles/rancher/tasks/rancher_agent.yml
+++ b/ansible/roles/rancher/tasks/rancher_agent.yml
@@ -7,7 +7,6 @@
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/var/lib/rancher:/var/lib/rancher"
- auto_remove: true
privileged: true
vars:
server_hostvars: "{{ hostvars[groups.infrastructure.0] }}"
diff --git a/ansible/test/roles/prepare-common/tasks/main.yml b/ansible/test/roles/prepare-common/tasks/main.yml
index 11dcbe71..909d58c9 100644
--- a/ansible/test/roles/prepare-common/tasks/main.yml
+++ b/ansible/test/roles/prepare-common/tasks/main.yml
@@ -1,31 +1,4 @@
---
-- name: Fetch docker host ip
- block:
- - name: Get docker host ip to access host where container running (as dood)
- shell: |
- set -o pipefail
- ip route | awk '/default/ { print $3 }'
- args:
- executable: /bin/bash
- register: ip
- changed_when: false
-
- - name: "set docker host ip {{ ip.stdout }} for cluster_ip"
- set_fact:
- cluster_ip: "{{ ip.stdout }}"
- when: inventory_hostname != 'localhost'
-
-- name: Set fact for localhost OS
- block:
- - name: set localhost fact
- set_fact:
- localhost_ansible_os_family: "{{ hostvars['localhost'].ansible_os_family }}"
-
- - name: debug
- debug:
- var: localhost_ansible_os_family
- when: hostvars['localhost'].ansible_os_family is defined
-
-- name: debug
- debug:
- var: ansible_os_family \ No newline at end of file
+- name: "Set cluster_ip fact"
+ set_fact:
+ cluster_ip: "{{ ansible_default_ipv4.address }}"