Merge "minor documentation updates"
diff --git a/ansible/library/docker_list_containers.py b/ansible/library/docker_list_containers.py
new file mode 100644
index 0000000..d8a789c
--- /dev/null
+++ b/ansible/library/docker_list_containers.py
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+
+ANSIBLE_METADATA = {
+ 'metadata_version': '1.1',
+ 'status': ['preview'],
+ 'supported_by': 'community'
+}
+
+DOCUMENTATION = '''
+---
+module: docker_list_containers
+
+short_description: "List running docker containers"
+
+description:
+ - "Lists all running containers or those with matching label"
+
+options:
+ label_name:
+ description:
+ - container label name to match
+ required: false
+ label_value:
+ description:
+ - container label value to match
+ required: false
+
+author:
+ - Bartek Grzybowski (b.grzybowski@partner.samsung.com)
+'''
+
+EXAMPLES = '''
+# List all running containers
+- name: List containers
+ docker_list_containers:
+
+# List all running containers matching label
+- name: List containers
+ docker_list_containers:
+ label_name: 'io.rancher.project.name'
+ label_value: 'kubernetes'
+'''
+
+RETURN = '''
+containers:
+ description: List of running containers matching module criteria
+ type: list
+ returned: always
+ sample: [
+ "rancher-agent",
+ "rancher-server",
+ "kubernetes-node-1",
+ "infrastructure-server"
+ ]
+'''
+
+from ansible.module_utils.docker_common import AnsibleDockerClient
+
+class DockerListContainers:
+
+ def __init__(self):
+ self.docker_client = AnsibleDockerClient(
+ argument_spec=dict(
+ label_name=dict(type='str', required=False),
+ label_value=dict(type='str', required=False)
+ )
+ )
+
+ self.containers = self.docker_client.containers()
+ self.label_name=self.docker_client.module.params.get('label_name')
+ self.label_value=self.docker_client.module.params.get('label_value')
+
+ if self.label_name:
+ self.containers_names=self._get_containers_names_by_label()
+ else:
+ self.containers_names=self._get_containers_names()
+
+ self.result=dict(
+ containers=self.containers_names,
+ changed=False
+ )
+
+ def _get_containers_names(self):
+ return [str(container_meta.get('Names')[0][1:]) for container_meta in self.containers if 'Names' in container_meta]
+
+ def _get_containers_names_by_label(self):
+ names=[]
+ for container_meta in self.containers:
+ if container_meta.get('Labels',{}).get(self.label_name) == self.label_value:
+ names.append(str(container_meta['Names'][0][1:])) # strip leading '/' in container name and convert to str from unicode
+
+ return names
+
+def main():
+ cont=DockerListContainers()
+ cont.docker_client.module.exit_json(**cont.result)
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible/roles/rancher/molecule/default/cleanup.yml b/ansible/roles/rancher/molecule/default/cleanup.yml
index 13b4827..d4bf449 100644
--- a/ansible/roles/rancher/molecule/default/cleanup.yml
+++ b/ansible/roles/rancher/molecule/default/cleanup.yml
@@ -7,8 +7,8 @@
container_list:
- rancher-agent
- rancher-server
- # For some reason getting error "Device busy error" when trying to delete directory with root privileges and rancher-containers not anymore running.
- # - role: cleanup-directories
- # vars:
- # directories_files_list_to_remove:
- # - /var/lib/rancher/
+ - 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/tasks/rancher_server.yml b/ansible/roles/rancher/tasks/rancher_server.yml
index 4cda372..a0893b0 100644
--- a/ansible/roles/rancher/tasks/rancher_server.yml
+++ b/ansible/roles/rancher/tasks/rancher_server.yml
@@ -55,7 +55,7 @@
account_key: "{{ key_public }}:{{ key_private }}"
mode: access_control
data:
- account_id: 1a1 # default rancher admin account
+ account_id: 1a1 # default rancher admin account
password: "{{ rancher.admin_password }}"
when: "rancher.auth_enabled is defined and rancher.auth_enabled"
diff --git a/ansible/test/bin/molecule.sh b/ansible/test/bin/molecule.sh
index d983ca0..72dce6d 100755
--- a/ansible/test/bin/molecule.sh
+++ b/ansible/test/bin/molecule.sh
@@ -42,7 +42,7 @@
MOLECULE_IMAGE_VERSION=${MOLECULE_IMAGE_VERSION:-2.20.0}
echo "Running molecule image: ${MOLECULE_IMAGE}:${MOLECULE_IMAGE_VERSION}"
MOLECULE_CMD=${MOLECULE_CMD:-molecule}
-docker run --rm -it \
+docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${ROOT_DIR}:${CONTAINER_ROOT}:rw \
-w ${CONTAINER_ROOT}/${PROJECT_ROOT_IN_CONTAINER} \
diff --git a/ansible/test/images/docker/build-all.sh b/ansible/test/images/docker/build-all.sh
index dd5db09..dcaaf82 100755
--- a/ansible/test/images/docker/build-all.sh
+++ b/ansible/test/images/docker/build-all.sh
@@ -19,9 +19,9 @@
# COPYRIGHT NOTICE ENDS HERE
BUILD_SCRIPT=${1:-build.sh}
-
+SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
# Run all build scripts in direct subdirectories
-for buildfile in $(find -mindepth 2 -maxdepth 2 -name ${BUILD_SCRIPT});
+for buildfile in $(find ${SCRIPTPATH} -mindepth 2 -maxdepth 2 -name ${BUILD_SCRIPT});
do
pushd $(dirname ${buildfile})
. ${BUILD_SCRIPT}
diff --git a/ansible/test/roles/cleanup-rancher/tasks/main.yml b/ansible/test/roles/cleanup-rancher/tasks/main.yml
new file mode 100644
index 0000000..21b0298
--- /dev/null
+++ b/ansible/test/roles/cleanup-rancher/tasks/main.yml
@@ -0,0 +1,18 @@
+---
+# Remove containers spawned by Rancher Agent
+- name: Get list of containers spawned by Rancher Agent
+ docker_list_containers:
+ label_name: "{{ item.label }}"
+ label_value: "{{ item.value }}"
+ loop: "{{ container_list_by_label }}"
+ register: docker_list_containers_var
+
+- name: set fact # save a list of containers found by previous task to orphaned_containers var
+ set_fact: orphaned_containers="{{ orphaned_containers|default([]) + item.containers }}"
+ loop: "{{ docker_list_containers_var.results }}"
+
+- name: Remove orphaned containers
+ docker_container:
+ name: "{{ item }}"
+ state: absent
+ loop: "{{ orphaned_containers }}"
diff --git a/ansible/test/roles/prepare-docker/tasks/docker-packages.yml b/ansible/test/roles/prepare-docker/tasks/docker-packages.yml
new file mode 100644
index 0000000..b7e76c5
--- /dev/null
+++ b/ansible/test/roles/prepare-docker/tasks/docker-packages.yml
@@ -0,0 +1,8 @@
+---
+
+- name: Download docker related packages
+ command: yumdownloader --destdir="{{ rpm_dir }}" "{{ docker_ce_rpm }}" "{{ docker_ce_selinux_rpm }}"
+
+- name: Install docker related packages
+ yum:
+ name: "{{ rpm_dir + '/' + docker_ce_rpm + '.rpm'}},{{ rpm_dir + '/' + docker_ce_selinux_rpm + '.rpm' }}"
diff --git a/ansible/test/roles/prepare-docker/tasks/prepare-docker-repos.yml b/ansible/test/roles/prepare-docker/tasks/prepare-docker-repos.yml
index 26f89d6..f35ffee 100644
--- a/ansible/test/roles/prepare-docker/tasks/prepare-docker-repos.yml
+++ b/ansible/test/roles/prepare-docker/tasks/prepare-docker-repos.yml
@@ -7,8 +7,16 @@
gpgcheck: true
gpgkey: https://download.docker.com/linux/centos/gpg
-- name: Install docker python bindings
- import_tasks: python-bindings.yml
+- name: Create rpm dir
+ file:
+ path: "{{ rpm_dir }}"
+ state: directory
+
+- name: Handle python2-docker dependency needed by Ansible's docker_* modules
+ import_tasks: python2-docker.yml
+
+- name: Handle docker-ce packages
+ import_tasks: docker-packages.yml
- name: Fake dockerd on container
import_tasks: docker-socket-override.yml
diff --git a/ansible/test/roles/prepare-docker/tasks/python-bindings.yml b/ansible/test/roles/prepare-docker/tasks/python-bindings.yml
deleted file mode 100644
index 7a66a32..0000000
--- a/ansible/test/roles/prepare-docker/tasks/python-bindings.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- name: Handle python2-docker dependency needed by Ansible's docker_* modules
- import_tasks: python2-docker.yml
diff --git a/ansible/test/roles/prepare-docker/tasks/python2-docker.yml b/ansible/test/roles/prepare-docker/tasks/python2-docker.yml
index 9cb3b48..f091cf8 100644
--- a/ansible/test/roles/prepare-docker/tasks/python2-docker.yml
+++ b/ansible/test/roles/prepare-docker/tasks/python2-docker.yml
@@ -4,35 +4,13 @@
name: docker-python
state: absent
-- name: Create own-repo dir
- file:
- path: /root/own-repo
- state: directory
-
- name: Download python2-docker rpm for Ansible (docker_container module dep)
get_url:
- url: https://cbs.centos.org/kojifiles/packages/python-docker/2.5.1/2.el7/noarch/python2-docker-2.5.1-2.el7.noarch.rpm
- dest: /root/own-repo/
+ url: "{{ python2_docker_rpm_url }}"
+ dest: "{{ rpm_dir }}"
register: rpm
-- name: Install createrepo
- package:
- name: createrepo
- state: present
-
-- name: Run createrepo
- command: createrepo /root/own-repo/
- when: rpm.changed
-
-- name: Create own-repo
- yum_repository:
- name: own-repo
- description: Own repo for ansible deps
- baseurl: file:///root/own-repo
- enabled: true
- gpgcheck: false
-
- name: Install docker python module
package:
- name: python2-docker
+ name: "{{ rpm_dir + '/' + python2_docker_rpm }}"
state: present
diff --git a/ansible/test/roles/prepare-docker/vars/main.yml b/ansible/test/roles/prepare-docker/vars/main.yml
index c63c0de..aabd65d 100644
--- a/ansible/test/roles/prepare-docker/vars/main.yml
+++ b/ansible/test/roles/prepare-docker/vars/main.yml
@@ -2,6 +2,9 @@
docker_needed_repos:
- /etc/yum.repos.d/CentOS-Base.repo.disabled
- /etc/yum.repos.d/docker-ce.repo.disabled
- - /etc/yum.repos.d/own-repo.repo.disabled
-
-offline_repo_file: /etc/yum.repos.d/onap.repo
\ No newline at end of file
+offline_repo_file: /etc/yum.repos.d/onap.repo
+rpm_dir: /root/rpm
+python2_docker_rpm: python2-docker-2.5.1-2.el7.noarch.rpm
+python2_docker_rpm_url: "https://cbs.centos.org/kojifiles/packages/python-docker/2.5.1/2.el7/noarch/{{ python2_docker_rpm }}"
+docker_ce_rpm: docker-ce-17.03.2.ce-1.el7.centos.x86_64
+docker_ce_selinux_rpm: docker-ce-selinux-17.03.3.ce-1.el7.noarch
diff --git a/build/data_lists/onap_3.0.2-docker_images.list b/build/data_lists/onap_3.0.2-docker_images.list
old mode 100644
new mode 100755
index e652a12..eba4451
--- a/build/data_lists/onap_3.0.2-docker_images.list
+++ b/build/data_lists/onap_3.0.2-docker_images.list
@@ -53,7 +53,7 @@
nexus3.onap.org:10001/onap/appc-cdt-image:1.4.4
nexus3.onap.org:10001/onap/appc-image:1.4.4
nexus3.onap.org:10001/onap/babel:1.3.3
-nexus3.onap.org:10001/onap/ccsdk-ansible-server-image:0.3.3
+nexus3.onap.org:10001/onap/ccsdk-ansible-server-image:0.3.4
nexus3.onap.org:10001/onap/ccsdk-apps-ms-neng:0.3.3
nexus3.onap.org:10001/onap/ccsdk-controllerblueprints:0.3.3
nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image:0.3.3
@@ -111,10 +111,10 @@
nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.policy-handler:4.4.0
nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.servicechange-handler:1.1.5
nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.prh.prh-app-server:1.1.1
-nexus3.onap.org:10001/onap/policy-apex-pdp:2.0.4
-nexus3.onap.org:10001/onap/policy-distribution:2.0.5
-nexus3.onap.org:10001/onap/policy-drools:1.3.6
-nexus3.onap.org:10001/onap/policy-pe:1.3.6
+nexus3.onap.org:10001/onap/policy-apex-pdp:2.0.5
+nexus3.onap.org:10001/onap/policy-distribution:2.0.6
+nexus3.onap.org:10001/onap/policy-drools:1.3.7
+nexus3.onap.org:10001/onap/policy-pe:1.3.7
nexus3.onap.org:10001/onap/pomba-aai-context-builder:1.3.2
nexus3.onap.org:10001/onap/pomba-context-aggregator:1.3.4
nexus3.onap.org:10001/onap/pomba-network-discovery-context-builder:1.3.1
@@ -133,7 +133,7 @@
nexus3.onap.org:10001/onap/sdc-kibana:1.3.6
nexus3.onap.org:10001/onap/sdc-onboard-backend:1.3.6
nexus3.onap.org:10001/onap/sdc-onboard-cassandra-init:1.3.6
-nexus3.onap.org:10001/onap/sdnc-ansible-server-image:1.4.4
+nexus3.onap.org:10001/onap/sdnc-ansible-server-image:1.4.5
nexus3.onap.org:10001/onap/sdnc-dmaap-listener-image:1.4.4
nexus3.onap.org:10001/onap/sdnc-image:1.4.4
nexus3.onap.org:10001/onap/sdnc-ueb-listener-image:1.4.4
@@ -182,7 +182,6 @@
nexus3.onap.org:10001/zookeeper:3.4
oomk8s/mariadb-client-init:3.0.0
oomk8s/readiness-check:2.0.0
-oomk8s/readiness-check:2.0.0
oomk8s/readiness-check:2.0.1
oomk8s/ubuntu-init:1.0.0
registry.hub.docker.com/library/busybox:latest
@@ -217,4 +216,4 @@
rancher/network-manager:v0.7.22
rancher/pause-amd64:3.0
rancher/server:v1.6.22
-rancher/tiller:v2.9.1
\ No newline at end of file
+rancher/tiller:v2.9.1