diff --git a/ansible/roles/cinder/tasks/bootstrap.yml b/ansible/roles/cinder/tasks/bootstrap.yml index c9eeb4ed27..10418c9732 100644 --- a/ansible/roles/cinder/tasks/bootstrap.yml +++ b/ansible/roles/cinder/tasks/bootstrap.yml @@ -37,3 +37,17 @@ - include: bootstrap_service.yml when: database_created + +- name: Creating cinder targets volume + kolla_docker: + action: "create_volume" + common_options: "{{ docker_common_options }}" + name: "cinder" + when: "{{ enable_iscsi | bool }}" + +- name: Creating iscsi info volume + kolla_docker: + action: "create_volume" + common_options: "{{ docker_common_options }}" + name: "iscsi_info" + when: "{{ enable_iscsi | bool }}" diff --git a/ansible/roles/cinder/tasks/start.yml b/ansible/roles/cinder/tasks/start.yml index 715695e9cb..6200ebc0de 100644 --- a/ansible/roles/cinder/tasks/start.yml +++ b/ansible/roles/cinder/tasks/start.yml @@ -21,6 +21,16 @@ - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['cinder-scheduler'] +- name: Prepare volumes list + set_fact: + mounts: + - "{{ node_config_directory }}/cinder-volume/:{{ container_config_directory }}/:ro" + - "/dev/:/dev/" + - "/run/:/run/" + - "{% if enable_iscsi | bool %}cinder:/var/lib/cinder{% endif %}" + - "{% if enable_iscsi | bool %}iscsi_info:/etc/iscsi{% endif %}" + - "kolla_logs:/var/log/kolla/" + - name: Starting cinder-volume container kolla_docker: action: "start_container" @@ -28,11 +38,8 @@ name: "cinder_volume" image: "{{ cinder_volume_image_full }}" privileged: True - volumes: - - "{{ node_config_directory }}/cinder-volume/:{{ container_config_directory }}/:ro" - - "/dev/:/dev/" - - "/run/:/run/" - - "kolla_logs:/var/log/kolla/" + ipc_mode: "host" + volumes: '{{ mounts | reject("equalto", "") | list}}' when: inventory_hostname in groups['cinder-volume'] - name: Starting cinder-backup container diff --git a/ansible/roles/iscsi/defaults/main.yml b/ansible/roles/iscsi/defaults/main.yml new file mode 100644 index 0000000000..9af4cbbd31 --- /dev/null +++ b/ansible/roles/iscsi/defaults/main.yml @@ -0,0 +1,13 @@ +--- +project_name: "iscsi" + +#################### +# Docker +#################### +iscsid_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-iscsid" +iscsid_tag: "{{ openstack_release }}" +iscsid_image_full: "{{ iscsid_image }}:{{ iscsid_tag }}" + +tgtd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-tgtd" +tgtd_tag: "{{ openstack_release }}" +tgtd_image_full: "{{ tgtd_image }}:{{ tgtd_tag }}" diff --git a/ansible/roles/iscsi/tasks/config.yml b/ansible/roles/iscsi/tasks/config.yml new file mode 100644 index 0000000000..8976537650 --- /dev/null +++ b/ansible/roles/iscsi/tasks/config.yml @@ -0,0 +1,34 @@ +--- +- name: Ensuring config directories exist + file: + path: "{{ node_config_directory }}/{{ item }}" + state: "directory" + recurse: yes + when: inventory_hostname in groups['compute'] + with_items: + - "iscsid" + +- name: Copying over config.json files for services + template: + src: "{{ item }}.json.j2" + dest: "{{ node_config_directory }}/{{ item }}/config.json" + when: inventory_hostname in groups['compute'] + with_items: + - "iscsid" + +- name: Ensuring config directories exist + file: + path: "{{ node_config_directory }}/{{ item }}" + state: "directory" + recurse: yes + when: inventory_hostname in groups['tgtd'] + with_items: + - "tgtd" + +- name: Copying over config.json files for services + template: + src: "{{ item }}.json.j2" + dest: "{{ node_config_directory }}/{{ item }}/config.json" + when: inventory_hostname in groups['tgtd'] + with_items: + - "tgtd" diff --git a/ansible/roles/iscsi/tasks/deploy.yml b/ansible/roles/iscsi/tasks/deploy.yml new file mode 100644 index 0000000000..1f16915ad9 --- /dev/null +++ b/ansible/roles/iscsi/tasks/deploy.yml @@ -0,0 +1,4 @@ +--- +- include: config.yml + +- include: start.yml diff --git a/ansible/roles/iscsi/tasks/main.yml b/ansible/roles/iscsi/tasks/main.yml new file mode 100644 index 0000000000..b017e8b4ad --- /dev/null +++ b/ansible/roles/iscsi/tasks/main.yml @@ -0,0 +1,2 @@ +--- +- include: "{{ action }}.yml" diff --git a/ansible/roles/iscsi/tasks/pull.yml b/ansible/roles/iscsi/tasks/pull.yml new file mode 100644 index 0000000000..33b10edd99 --- /dev/null +++ b/ansible/roles/iscsi/tasks/pull.yml @@ -0,0 +1,7 @@ +--- +- name: Pulling iscsi image + kolla_docker: + action: "pull_image" + common_options: "{{ docker_common_options }}" + image: "{{ iscsi_image_full }}" + when: inventory_hostname in groups['iscsi'] diff --git a/ansible/roles/iscsi/tasks/reconfigure.yml b/ansible/roles/iscsi/tasks/reconfigure.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/ansible/roles/iscsi/tasks/reconfigure.yml @@ -0,0 +1 @@ +--- diff --git a/ansible/roles/iscsi/tasks/start.yml b/ansible/roles/iscsi/tasks/start.yml new file mode 100644 index 0000000000..8d86558310 --- /dev/null +++ b/ansible/roles/iscsi/tasks/start.yml @@ -0,0 +1,40 @@ +--- +- name: Starting iscsid container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + image: "{{ iscsid_image_full }}" + name: "iscsid" + ipc_mode: "host" + privileged: True + volumes: + - "{{ node_config_directory }}/iscsid/:{{ container_config_directory }}/:ro" + - "kolla_logs:/var/log/kolla/" + - "/dev/:/dev/" + - "/run/:/run/" + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + - "/lib/modules:/lib/modules:ro" + - "/sys/kernel/config:/configfs" + - "cinder:/var/lib/cinder" + - "iscsi_info:/etc/iscsi" + when: inventory_hostname in groups['compute'] + +- name: Starting tgtd container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + image: "{{ tgtd_image_full }}" + name: "tgtd" + ipc_mode: "host" + privileged: True + volumes: + - "{{ node_config_directory }}/tgtd/:{{ container_config_directory }}/:ro" + - "kolla_logs:/var/log/kolla/" + - "/dev/:/dev/" + - "/run/:/run/" + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + - "/lib/modules:/lib/modules:ro" + - "/sys/kernel/config:/configfs" + - "cinder:/var/lib/cinder" + - "iscsi_info:/etc/iscsi" + when: inventory_hostname in groups['tgtd'] diff --git a/ansible/roles/iscsi/tasks/upgrade.yml b/ansible/roles/iscsi/tasks/upgrade.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/ansible/roles/iscsi/tasks/upgrade.yml @@ -0,0 +1 @@ +--- diff --git a/ansible/roles/iscsi/templates/iscsid.json.j2 b/ansible/roles/iscsi/templates/iscsid.json.j2 new file mode 100644 index 0000000000..f44cf16c97 --- /dev/null +++ b/ansible/roles/iscsi/templates/iscsid.json.j2 @@ -0,0 +1,4 @@ +{ + "command": "iscsid -d 8 -f --pid=/run/iscsid.pid", + "config_files": [] +} diff --git a/ansible/roles/iscsi/templates/tgtd.json.j2 b/ansible/roles/iscsi/templates/tgtd.json.j2 new file mode 100644 index 0000000000..0d74a78fda --- /dev/null +++ b/ansible/roles/iscsi/templates/tgtd.json.j2 @@ -0,0 +1,4 @@ +{ + "command": "tgtd -d 1 -f --iscsi portal={{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{ iscsi_port }}", + "config_files": [] +} diff --git a/ansible/roles/nova/tasks/start_compute.yml b/ansible/roles/nova/tasks/start_compute.yml index 1540f4673f..db38bb95d3 100644 --- a/ansible/roles/nova/tasks/start_compute.yml +++ b/ansible/roles/nova/tasks/start_compute.yml @@ -11,12 +11,25 @@ - "{{ node_config_directory }}/nova-libvirt/:{{ container_config_directory }}/:ro" - "/lib/modules:/lib/modules:ro" - "/run/:/run/" + - "/dev:/dev" - "/sys/fs/cgroup:/sys/fs/cgroup" - "kolla_logs:/var/log/kolla/" - "libvirtd:/var/lib/libvirt" - "nova_compute:/var/lib/nova/" when: inventory_hostname in groups['compute'] +- name: Prepare volumes list + set_fact: + mounts: + - "{{ node_config_directory }}/nova-compute/:{{ container_config_directory }}/:ro" + - "/lib/modules:/lib/modules:ro" + - "/run:/run" + - "/dev:/dev" + - "kolla_logs:/var/log/kolla/" + - "{% if enable_iscsi | bool %}iscsi_info:/etc/iscsi{% endif %}" + - "libvirtd:/var/lib/libvirt" + - "nova_compute:/var/lib/nova/" + - name: Starting nova-compute container kolla_docker: action: "start_container" @@ -24,13 +37,7 @@ image: "{{ nova_compute_image_full }}" name: "nova_compute" privileged: True - volumes: - - "{{ node_config_directory }}/nova-compute/:{{ container_config_directory }}/:ro" - - "/lib/modules:/lib/modules:ro" - - "/run:/run" - - "kolla_logs:/var/log/kolla/" - - "libvirtd:/var/lib/libvirt" - - "nova_compute:/var/lib/nova/" + volumes: '{{ mounts | reject("equalto", "") | list}}' when: - inventory_hostname in groups['compute'] - not enable_nova_fake | bool