From 20db1738fa0c23f14775eb44740a84b9fa867280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Udd=C3=A9n?= Date: Mon, 25 Sep 2017 13:29:17 +0200 Subject: [PATCH] feature: install project atomic CSS on RedHat family (#1499) * feature: install project atomic CSS on RedHat family * missing patch for this feature * sub-role refactor * Yamllint fix --- roles/docker/defaults/main.yml | 2 + roles/docker/docker-storage/defaults/main.yml | 15 ++++++++ .../files/install_container_storage_setup.sh | 22 +++++++++++ roles/docker/docker-storage/tasks/main.yml | 37 +++++++++++++++++++ .../templates/docker-storage-setup.j2 | 35 ++++++++++++++++++ roles/docker/meta/main.yml | 4 ++ 6 files changed, 115 insertions(+) create mode 100644 roles/docker/docker-storage/defaults/main.yml create mode 100644 roles/docker/docker-storage/files/install_container_storage_setup.sh create mode 100644 roles/docker/docker-storage/tasks/main.yml create mode 100644 roles/docker/docker-storage/templates/docker-storage-setup.j2 create mode 100644 roles/docker/meta/main.yml diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index 9da348cda..d07a9d627 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -12,5 +12,7 @@ docker_repo_info: docker_dns_servers_strict: yes +docker_container_storage_setup: false + docker_rh_repo_base_url: 'https://yum.dockerproject.org/repo/main/centos/7' docker_rh_repo_gpgkey: 'https://yum.dockerproject.org/gpg' diff --git a/roles/docker/docker-storage/defaults/main.yml b/roles/docker/docker-storage/defaults/main.yml new file mode 100644 index 000000000..9785dac47 --- /dev/null +++ b/roles/docker/docker-storage/defaults/main.yml @@ -0,0 +1,15 @@ +--- +docker_container_storage_setup_version: v0.6.0 +docker_container_storage_setup_profile_name: kubespray +docker_container_storage_setup_storage_driver: devicemapper +docker_container_storage_setup_container_thinpool: docker-pool +docker_container_storage_setup_data_size: 40%FREE +docker_container_storage_setup_min_data_size: 2G +docker_container_storage_setup_chunk_size: 512K +docker_container_storage_setup_growpart: false +docker_container_storage_setup_auto_extend_pool: yes +docker_container_storage_setup_pool_autoextend_threshold: 60 +docker_container_storage_setup_pool_autoextend_percent: 20 +docker_container_storage_setup_device_wait_timeout: 60 +docker_container_storage_setup_wipe_signatures: false +docker_container_storage_setup_container_root_lv_size: 40%FREE diff --git a/roles/docker/docker-storage/files/install_container_storage_setup.sh b/roles/docker/docker-storage/files/install_container_storage_setup.sh new file mode 100644 index 000000000..18f937b10 --- /dev/null +++ b/roles/docker/docker-storage/files/install_container_storage_setup.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +version=${1:-master} +profile_name=${2:-kubespray} +dir=`mktemp -d` +export GIT_DIR=$dir/.git +export GIT_WORK_TREE=$dir + +git init +git fetch --depth 1 https://github.com/projectatomic/container-storage-setup.git $version +git merge FETCH_HEAD +make -C $dir install +rm -rf /var/lib/container-storage-setup/$profile_name $dir + +set +e + +/usr/bin/container-storage-setup create $profile_name /etc/sysconfig/docker-storage-setup && /usr/bin/container-storage-setup activate $profile_name +# FIXME: exit status can be 1 for both fatal and non fatal errors in current release, +# could be improved by matching error strings +exit 0 diff --git a/roles/docker/docker-storage/tasks/main.yml b/roles/docker/docker-storage/tasks/main.yml new file mode 100644 index 000000000..4a80812ba --- /dev/null +++ b/roles/docker/docker-storage/tasks/main.yml @@ -0,0 +1,37 @@ +--- + +- name: docker-storage-setup | install git and make + with_items: [git, make] + package: + pkg: "{{ item }}" + state: present + +- name: docker-storage-setup | docker-storage-setup sysconfig template + template: + src: docker-storage-setup.j2 + dest: /etc/sysconfig/docker-storage-setup + +- name: docker-storage-override-directory | docker service storage-setup override dir + file: + dest: /etc/systemd/system/docker.service.d + mode: 0755 + owner: root + group: root + state: directory + +- name: docker-storage-override | docker service storage-setup override file + copy: + dest: /etc/systemd/system/docker.service.d/override.conf + content: |- + ### Thie file is managed by Ansible + [Service] + EnvironmentFile=-/etc/sysconfig/docker-storage + + owner: root + group: root + mode: 0644 + +- name: docker-storage-setup | install and run container-storage-setup + become: yes + script: install_container_storage_setup.sh {{ docker_container_storage_setup_version }} {{ docker_container_storage_setup_profile_name }} + notify: Docker | reload systemd diff --git a/roles/docker/docker-storage/templates/docker-storage-setup.j2 b/roles/docker/docker-storage/templates/docker-storage-setup.j2 new file mode 100644 index 000000000..1a502b2c9 --- /dev/null +++ b/roles/docker/docker-storage/templates/docker-storage-setup.j2 @@ -0,0 +1,35 @@ +{%if docker_container_storage_setup_storage_driver is defined%}STORAGE_DRIVER={{docker_container_storage_setup_storage_driver}}{%endif%} + +{%if docker_container_storage_setup_extra_storage_options is defined%}EXTRA_STORAGE_OPTIONS={{docker_container_storage_setup_extra_storage_options}}{%endif%} + +{%if docker_container_storage_setup_devs is defined%}DEVS={{docker_container_storage_setup_devs}}{%endif%} + +{%if docker_container_storage_setup_container_thinpool is defined%}CONTAINER_THINPOOL={{docker_container_storage_setup_container_thinpool}}{%endif%} + +{%if docker_container_storage_setup_vg is defined%}VG={{docker_container_storage_setup_vg}}{%endif%} + +{%if docker_container_storage_setup_root_size is defined%}ROOT_SIZE={{docker_container_storage_setup_root_size}}{%endif%} + +{%if docker_container_storage_setup_data_size is defined%}DATA_SIZE={{docker_container_storage_setup_data_size}}{%endif%} + +{%if docker_container_storage_setup_min_data_size is defined%}MIN_DATA_SIZE={{docker_container_storage_setup_min_data_size}}{%endif%} + +{%if docker_container_storage_setup_chunk_size is defined%}CHUNK_SIZE={{docker_container_storage_setup_chunk_size}}{%endif%} + +{%if docker_container_storage_setup_growpart is defined%}GROWPART={{docker_container_storage_setup_growpart}}{%endif%} + +{%if docker_container_storage_setup_auto_extend_pool is defined%}AUTO_EXTEND_POOL={{docker_container_storage_setup_auto_extend_pool}}{%endif%} + +{%if docker_container_storage_setup_pool_autoextend_threshold is defined%}POOL_AUTOEXTEND_THRESHOLD={{docker_container_storage_setup_pool_autoextend_threshold}}{%endif%} + +{%if docker_container_storage_setup_pool_autoextend_percent is defined%}POOL_AUTOEXTEND_PERCENT={{docker_container_storage_setup_pool_autoextend_percent}}{%endif%} + +{%if docker_container_storage_setup_device_wait_timeout is defined%}DEVICE_WAIT_TIMEOUT={{docker_container_storage_setup_device_wait_timeout}}{%endif%} + +{%if docker_container_storage_setup_wipe_signatures is defined%}WIPE_SIGNATURES={{docker_container_storage_setup_wipe_signatures}}{%endif%} + +{%if docker_container_storage_setup_container_root_lv_name is defined%}CONTAINER_ROOT_LV_NAME={{docker_container_storage_setup_container_root_lv_name}}{%endif%} + +{%if docker_container_storage_setup_container_root_lv_size is defined%}CONTAINER_ROOT_LV_SIZE={{docker_container_storage_setup_container_root_lv_size}}{%endif%} + +{%if docker_container_storage_setup_container_root_lv_mount_path is defined%}CONTAINER_ROOT_LV_MOUNT_PATH={{docker_container_storage_setup_container_root_lv_mount_path}}{%endif%} diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml new file mode 100644 index 000000000..2adfe16ca --- /dev/null +++ b/roles/docker/meta/main.yml @@ -0,0 +1,4 @@ +--- +dependencies: + - role: docker/docker-storage + when: docker_container_storage_setup and ansible_os_family == "RedHat"