Usage of kolla_container_engine variable instead of docker

First part of patchset:
 https://review.opendev.org/c/openstack/kolla-ansible/+/799229/
in which was suggested to split patch into smaller ones.

This implements kolla_container_engine variable
in command calls of docker,so later on it can be
also used for podman without further change.

Signed-off-by: Ivan Halomi <i.halomi@partner.samsung.com>
Change-Id: Ic30b67daa2e215524096ad1f4385c569e3d41b95
This commit is contained in:
Ivan Halomi 2022-10-26 20:33:22 +02:00
parent f9bc6b10a5
commit 910f9bd36f
37 changed files with 71 additions and 60 deletions

View File

@ -86,6 +86,10 @@ database_port: "3306"
database_connection_recycle_time: 10
database_max_pool_size: 1
####################
# Container engine options
####################
kolla_container_engine: "docker"
####################
# Docker options

View File

@ -5,7 +5,7 @@
is_debian: "{{ kolla_base_distro in ['debian', 'ubuntu'] }}"
become: true
command: >
docker exec bifrost_deploy
{{ kolla_container_engine }} exec bifrost_deploy
bash -c 'mkdir -p /var/log/kolla/ironic &&
chown ironic:ironic /var/log/kolla/ironic &&
mkdir -p /var/log/kolla/ironic-inspector &&
@ -16,7 +16,7 @@
- name: Bootstrap bifrost (this may take several minutes)
become: true
command: >
docker exec bifrost_deploy
{{ kolla_container_engine }} exec bifrost_deploy
bash -c
'ansible-playbook {{ bifrost_deploy_verbosity }}
-i /bifrost/playbooks/inventory/target
@ -26,7 +26,7 @@
- name: Installing ssh keys
become: true
command: >
docker exec bifrost_deploy
{{ kolla_container_engine }} exec bifrost_deploy
bash -c 'mkdir /root/.ssh ; mkdir /home/ironic/.ssh;
cp -f /etc/bifrost/id_rsa /root/.ssh/id_rsa &&
cp -f /etc/bifrost/id_rsa.pub /root/.ssh/id_rsa.pub &&

View File

@ -2,7 +2,7 @@
- name: Enrolling physical servers with ironic
become: true
command: >
docker exec bifrost_deploy
{{ kolla_container_engine }} exec bifrost_deploy
bash -c 'export OS_CLOUD=bifrost &&
export BIFROST_INVENTORY_SOURCE=/etc/bifrost/servers.yml &&
ansible-playbook {{ bifrost_deploy_verbosity }}}
@ -12,7 +12,7 @@
- name: Deploy physical servers with ironic
become: true
command: >
docker exec bifrost_deploy
{{ kolla_container_engine }} exec bifrost_deploy
bash -c 'export OS_CLOUD=bifrost &&
export BIFROST_INVENTORY_SOURCE=/etc/bifrost/servers.yml &&
ansible-playbook {{ bifrost_deploy_verbosity }}

View File

@ -14,7 +14,7 @@
- name: Check the configs
become: true
command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
command: "{{ kolla_container_engine }} exec {{ item.name }} /usr/local/bin/kolla_set_configs --check"
changed_when: false
failed_when: false
register: check_results

View File

@ -12,7 +12,7 @@
# order.
- name: Stop services gracefully
become: true
command: docker exec bifrost_deploy systemctl stop {{ item }}.service
command: "{{ kolla_container_engine }} exec bifrost_deploy systemctl stop {{ item }}.service"
with_items:
- ironic
- ironic-inspector

View File

@ -36,7 +36,7 @@
- name: Initializing toolbox container using normal user
become: true
command: docker exec -t "{{ common_services['kolla-toolbox']['container_name'] }}" ansible --version
command: "{{ kolla_container_engine }} exec -t {{ common_services['kolla-toolbox']['container_name'] }} ansible --version"
changed_when: false
- name: Restart cron container

View File

@ -1,6 +1,6 @@
---
- name: Update DNS pools
become: true
command: docker exec -t designate_worker designate-manage pool update --file /etc/designate/pools.yaml
command: "{{ kolla_container_engine }} exec -t designate_worker designate-manage pool update --file /etc/designate/pools.yaml"
run_once: True
delegate_to: "{{ groups['designate-worker'][0] }}"

View File

@ -2,7 +2,7 @@
- name: Ensure stonith is disabled
vars:
service: "{{ hacluster_services['hacluster-pacemaker'] }}"
command: docker exec {{ service.container_name }} crm_attribute --type crm_config --name stonith-enabled --update false
command: "{{ kolla_container_engine }} exec {{ service.container_name }} crm_attribute --type crm_config --name stonith-enabled --update false"
run_once: true
become: true
delegate_to: "{{ groups[service.group][0] }}"
@ -12,7 +12,7 @@
pacemaker_service: "{{ hacluster_services['hacluster-pacemaker'] }}"
pacemaker_remote_service: "{{ hacluster_services['hacluster-pacemaker-remote'] }}"
shell: >
docker exec {{ pacemaker_service.container_name }}
{{ kolla_container_engine }} exec {{ pacemaker_service.container_name }}
cibadmin --modify --scope resources -X '
<resources>
<primitive id="{{ ansible_facts.hostname }}" class="ocf" provider="pacemaker" type="remote">

View File

@ -2,7 +2,7 @@
- name: Wait for Ironic nodes not to wait
become: true
command: >
docker exec kolla_toolbox openstack
{{ kolla_container_engine }} exec kolla_toolbox openstack
--os-interface {{ openstack_interface }}
--os-auth-url {{ openstack_auth.auth_url }}
--os-username {{ openstack_auth.username }}

View File

@ -11,7 +11,7 @@
- name: Run key distribution
become: true
command: docker exec -t "{{ keystone_services['keystone-fernet']['container_name'] }}" /usr/bin/fernet-push.sh
command: "{{ kolla_container_engine }} exec -t {{ keystone_services['keystone-fernet']['container_name'] }} /usr/bin/fernet-push.sh"
run_once: True
delegate_to: >-
{% if groups['keystone_fernet_running'] is defined -%}

View File

@ -2,7 +2,7 @@
- name: Creating admin project, user, role, service, and endpoint
become: true
command: >
docker exec keystone kolla_keystone_bootstrap
{{ kolla_container_engine }} exec keystone kolla_keystone_bootstrap
{{ openstack_auth.username }} {{ openstack_auth.password }} {{ keystone_admin_project }}
admin {{ keystone_internal_url }} {{ keystone_public_url }} {{ item }}
register: keystone_bootstrap

View File

@ -1,7 +1,7 @@
---
- name: List configured attribute mappings (that can be used by IdPs)
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -22,7 +22,7 @@
- name: Remove unmanaged attribute mappings
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -57,7 +57,7 @@
- name: Register attribute mappings in OpenStack
become: true
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -78,7 +78,7 @@
- name: Update existing attribute mappings in OpenStack
become: true
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -99,7 +99,7 @@
- name: List configured IdPs
become: true
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -120,7 +120,7 @@
- name: Remove unmanaged identity providers
become: true
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -140,7 +140,7 @@
- name: Register Identity Providers in OpenStack
become: true
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -163,7 +163,7 @@
- name: Update Identity Providers in OpenStack according to Kolla-Ansible configurations
become: true
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -185,7 +185,7 @@
- name: Configure attribute mappings for each Identity Provider. (We expect the mappings to be configured by the operator)
become: true
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
@ -207,7 +207,7 @@
- name: Update attribute mappings for each Identity Provider. (We expect the mappings to be configured by the operator).
become: true
command: >
docker exec -t keystone openstack
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}

View File

@ -194,7 +194,7 @@
- name: Getting haproxy stat
become: true
shell: echo "show stat" | docker exec -i haproxy socat unix-connect:/var/lib/kolla/haproxy/haproxy.sock stdio # noqa risky-shell-pipe
shell: echo "show stat" | {{ kolla_container_engine }} exec -i haproxy socat unix-connect:/var/lib/kolla/haproxy/haproxy.sock stdio # noqa risky-shell-pipe
register: haproxy_stat_shell
changed_when: false
when: container_facts['haproxy'] is defined

View File

@ -36,7 +36,7 @@
- name: Wait for first MariaDB service to sync WSREP
become: true
command: >-
docker exec {{ mariadb_service.container_name }}
{{ kolla_container_engine }} exec {{ mariadb_service.container_name }}
mysql -uroot -p{{ database_password }}
--silent --skip-column-names
-e 'SHOW STATUS LIKE "wsrep_local_state_comment"'

View File

@ -5,7 +5,7 @@
- name: Wait for MariaDB service to be ready through VIP
become: true
command: >
docker exec {{ mariadb_service.container_name }}
{{ kolla_container_engine }} exec {{ mariadb_service.container_name }}
mysql -h {{ database_address }} -P {{ database_port }}
-u {{ mariadb_shard_database_user }} -p{{ database_password }} -e 'show databases;'
register: result

View File

@ -45,7 +45,7 @@
- name: Check MariaDB service WSREP sync status
become: true
command: >-
docker exec {{ mariadb_service.container_name }}
{{ kolla_container_engine }} exec {{ mariadb_service.container_name }}
mysql -uroot -p{{ database_password }}
--silent --skip-column-names
-e 'SHOW STATUS LIKE "wsrep_local_state_comment"'

View File

@ -142,7 +142,7 @@
- name: Set first MariaDB container as primary
become: true
shell: "docker exec {{ mariadb_service.container_name }} mysql -uroot -p{{ database_password }} -e \"SET GLOBAL wsrep_provider_options='pc.bootstrap=yes';\""
shell: "{{ kolla_container_engine }} exec {{ mariadb_service.container_name }} mysql -uroot -p{{ database_password }} -e \"SET GLOBAL wsrep_provider_options='pc.bootstrap=yes';\""
no_log: True
when:
- bootstrap_host is defined
@ -151,7 +151,7 @@
- name: Wait for MariaDB to become operational
become: true
command: >-
docker exec {{ mariadb_service.container_name }}
{{ kolla_container_engine }} exec {{ mariadb_service.container_name }}
mysql -uroot -p{{ database_password }}
--silent --skip-column-names
-e 'SHOW STATUS LIKE "wsrep_evs_state"'

View File

@ -30,7 +30,7 @@
- name: Wait for MariaDB service to sync WSREP
become: true
command: >-
docker exec {{ mariadb_service.container_name }}
{{ kolla_container_engine }} exec {{ mariadb_service.container_name }}
mysql -uroot -p{{ database_password }}
--silent --skip-column-names
-e 'SHOW STATUS LIKE "wsrep_local_state_comment"'

View File

@ -44,7 +44,7 @@
# [1] https://github.com/influxdata/influxdb-python#influxdb-pre-v110-users
- name: List influxdb databases
become: true
command: "docker exec influxdb influx -host {{ monasca_influxdb_address }} -port {{ monasca_influxdb_http_port }} -execute 'show databases'"
command: "{{ kolla_container_engine }} exec influxdb influx -host {{ monasca_influxdb_address }} -port {{ monasca_influxdb_http_port }} -execute 'show databases'"
run_once: True
delegate_to: "{{ groups['influxdb'][0] }}"
register: monasca_influxdb_database
@ -53,7 +53,7 @@
- name: Creating monasca influxdb database
become: true
command: >
docker exec influxdb influx -host {{ monasca_influxdb_address }} -port {{ monasca_influxdb_http_port }} -execute
{{ kolla_container_engine }} exec influxdb influx -host {{ monasca_influxdb_address }} -port {{ monasca_influxdb_http_port }} -execute
'CREATE DATABASE {{ monasca_influxdb_name }} WITH DURATION {{ monasca_influxdb_retention_policy.duration }}
REPLICATION {{ monasca_influxdb_retention_policy.replication_count }} NAME {{ monasca_influxdb_retention_policy.name }}'
run_once: True
@ -68,7 +68,7 @@
- name: List monasca kafka topics
become: true
command: >
docker exec kafka /opt/kafka/bin/kafka-topics.sh
{{ kolla_container_engine }} exec kafka /opt/kafka/bin/kafka-topics.sh
--zookeeper localhost
--list
register: kafka_topics
@ -78,7 +78,7 @@
- name: Create monasca kafka topics if they don't exist
become: true
command: >
docker exec kafka /opt/kafka/bin/kafka-topics.sh
{{ kolla_container_engine }} exec kafka /opt/kafka/bin/kafka-topics.sh
--create
--topic {{ item.name }}
--partitions {{ item.partitions }}
@ -94,7 +94,7 @@
- name: Remove monasca kafka topics for disabled services
become: true
command: >
docker exec kafka /opt/kafka/bin/kafka-topics.sh
{{ kolla_container_engine }} exec kafka /opt/kafka/bin/kafka-topics.sh
--delete
--topic "{{ item.name }}"
--zookeeper localhost

View File

@ -15,7 +15,7 @@
- name: Checking if Murano core and applications library packages exist
become: true
command: >
docker exec murano_api murano
{{ kolla_container_engine }} exec murano_api murano
--os-username {{ openstack_auth.username }}
--os-password {{ openstack_auth.password }}
--os-system-scope {{ openstack_auth.system_scope }}
@ -31,7 +31,7 @@
- name: Importing Murano core library package
become: true
command: >
docker exec murano_api murano
{{ kolla_container_engine }} exec murano_api murano
--os-username {{ openstack_auth.username }}
--os-password {{ openstack_auth.password }}
--os-system-scope {{ openstack_auth.system_scope }}
@ -47,7 +47,7 @@
- name: Importing Murano applications library package
become: true
command: >
docker exec murano_api murano
{{ kolla_container_engine }} exec murano_api murano
--os-username {{ openstack_auth.username }}
--os-password {{ openstack_auth.password }}
--os-system-scope {{ openstack_auth.system_scope }}

View File

@ -37,7 +37,7 @@
- name: Checking neutron pending contract scripts
become: true
command: "docker exec -t neutron_server neutron-db-manage --subproject {{ item }} has_offline_migrations"
command: "{{ kolla_container_engine }} exec -t neutron_server neutron-db-manage --subproject {{ item }} has_offline_migrations"
register: neutron_check_contract_db_stdout
ignore_errors: yes
with_items: "{{ neutron_rolling_upgrade_services }}"

View File

@ -122,7 +122,7 @@
cmd: >
set -o pipefail &&
echo {{ libvirt_sasl_password }} |
docker exec -i nova_libvirt
{{ kolla_container_engine }} exec -i nova_libvirt
saslpasswd2 -c -p -a libvirt {{ libvirt_sasl_authname }}
executable: /bin/bash
changed_when: true

View File

@ -14,7 +14,7 @@
- name: Discover nova hosts
become: true
command: >
docker exec nova_conductor nova-manage cell_v2 discover_hosts --by-service --cell_uuid {{ nova_cell_settings.cell_uuid }}
{{ kolla_container_engine }} exec nova_conductor nova-manage cell_v2 discover_hosts --by-service --cell_uuid {{ nova_cell_settings.cell_uuid }}
changed_when: False
# Delegate to a cell conductor.

View File

@ -8,7 +8,7 @@
- name: Waiting for nova-compute services to register themselves
become: true
command: >
docker exec kolla_toolbox openstack
{{ kolla_container_engine }} exec kolla_toolbox openstack
--os-interface {{ openstack_interface }}
--os-auth-url {{ openstack_auth.auth_url }}
--os-username {{ openstack_auth.username }}

View File

@ -7,6 +7,6 @@
# Docker bug (https://github.com/moby/moby/issues/11065), this might cause the
# container to be stopped if we restart Docker or reboot the server as we
# use the 'unless-stopped' restart policy by default.
shell: "kill -HUP `docker inspect -f '{% raw %}{{ .State.Pid }}{% endraw %}' nova_scheduler`"
shell: "kill -HUP `{{ kolla_container_engine }} inspect -f '{% raw %}{{ .State.Pid }}{% endraw %}' nova_scheduler`"
when:
- inventory_hostname in groups['nova-scheduler']

View File

@ -1,7 +1,7 @@
---
- name: Check nova upgrade status
become: true
command: docker exec -t nova_api nova-status upgrade check
command: "{{ kolla_container_engine }} exec -t nova_api nova-status upgrade check"
register: nova_upgrade_check_stdout
when: inventory_hostname == groups['nova-api'][0]
failed_when: false

View File

@ -23,7 +23,7 @@
vars:
port_id: "{{ port_info.id }}"
command: >
docker exec kolla_toolbox openstack
{{ kolla_container_engine }} exec kolla_toolbox openstack
--os-interface {{ openstack_interface }}
--os-auth-url {{ octavia_user_auth.auth_url }}
--os-identity-api-version 3
@ -43,7 +43,7 @@
port_id: "{{ port_info.id }}"
become: True
command: >
docker exec openvswitch_vswitchd ovs-vsctl --may-exist \
{{ kolla_container_engine }} exec openvswitch_vswitchd ovs-vsctl --may-exist \
add-port br-int {{ octavia_network_interface }} \
-- set Interface {{ octavia_network_interface }} type=internal \
-- set Interface {{ octavia_network_interface }} external-ids:iface-status=active \

View File

@ -19,7 +19,7 @@
- name: Waiting for openvswitch_db service to be ready
become: true
command: docker exec openvswitch_db ovs-vsctl --no-wait show
command: "{{ kolla_container_engine }} exec openvswitch_db ovs-vsctl --no-wait show"
register: check_result
until: check_result is success
changed_when: False

View File

@ -18,7 +18,7 @@
- name: Ensuring OVS bridge is properly setup
become: true
command: docker exec openvswitch_db /usr/local/bin/kolla_ensure_openvswitch_configured {{ item.0 }} {{ item.1 }}
command: "{{ kolla_container_engine }} exec openvswitch_db /usr/local/bin/kolla_ensure_openvswitch_configured {{ item.0 }} {{ item.1 }}"
register: status
changed_when: status.stdout.find('changed') != -1
when:

View File

@ -26,7 +26,7 @@
service_name: "ovsdpdk-db"
service: "{{ ovsdpdk_services[service_name] }}"
become: true
command: docker exec "{{ service.container_name }}" ovs-vsctl --no-wait show
command: "{{ kolla_container_engine }} exec {{ service.container_name }} ovs-vsctl --no-wait show"
register: check_result
until: check_result is success
changed_when: False
@ -39,7 +39,7 @@
service: "{{ ovsdpdk_services[service_name] }}"
become: true
command: >
docker exec {{ service.container_name }} /bin/sh -c
{{ kolla_container_engine }} exec {{ service.container_name }} /bin/sh -c
'CONFIG_FILE={{ container_config_directory }}/ovs-dpdkctl.conf {{ container_config_directory }}/ovs-dpdkctl.sh init'
register: status
changed_when: status.stdout.find('changed') != -1
@ -73,7 +73,7 @@
service: "{{ ovsdpdk_services[service_name] }}"
become: true
command: >
docker exec {{ service.container_name }} /bin/sh -c
{{ kolla_container_engine }} exec {{ service.container_name }} /bin/sh -c
'CONFIG_FILE={{ container_config_directory }}/ovs-dpdkctl.conf {{ container_config_directory }}/ovs-dpdkctl.sh init'
register: status
changed_when: status.stdout.find('changed') != -1

View File

@ -1,7 +1,7 @@
---
- name: Checking Docker version
become: true
command: docker --version
command: "{{ kolla_container_engine }} --version"
register: result
changed_when: false
when: inventory_hostname in groups['baremetal']

View File

@ -19,4 +19,4 @@
service_name: "rabbitmq"
service: "{{ rabbitmq_services[service_name] }}"
become: true
command: "docker exec {{ service.container_name }} rabbitmqctl wait {{ rabbitmq_pid_file }}"
command: "{{ kolla_container_engine }} exec {{ service.container_name }} rabbitmqctl wait {{ rabbitmq_pid_file }}"

View File

@ -1,7 +1,7 @@
---
- name: Redis ping pong check
become: true
command: "docker exec redis redis-cli -h {{ api_interface_address }} -a {{ redis_master_password }} ping"
command: "{{ kolla_container_engine }} exec redis redis-cli -h {{ api_interface_address }} -a {{ redis_master_password }} ping"
register: redis_check
changed_when: "redis_check.stdout != 'PONG'"
failed_when: "redis_check.stdout != 'PONG'"

View File

@ -44,7 +44,7 @@
- name: Check the configs
become: true
command: docker exec -u root {{ item.name }} /usr/local/bin/kolla_set_configs --check
command: "{{ kolla_container_engine }}exec -u root {{ item.name }} /usr/local/bin/kolla_set_configs --check"
changed_when: false
failed_when: false
register: check_results

View File

@ -1,10 +1,10 @@
---
- name: Looking up disks for Swift
become: true
command: docker exec -t kolla_toolbox sudo -E ansible localhost
command: "{{ kolla_container_engine }} exec -t kolla_toolbox sudo -E ansible localhost
-m find_disks
-a "name={{ swift_devices_name }}
match_mode={{ swift_devices_match_mode }}"
-a \"name={{ swift_devices_name }}
match_mode={{ swift_devices_match_mode }}\""
register: swift_disk_lookup
changed_when: swift_disk_lookup.stdout.find('localhost | SUCCESS => ') != -1 and
(swift_disk_lookup.stdout.split('localhost | SUCCESS => ')[1] | from_json).changed

View File

@ -80,7 +80,7 @@
service_name: "zun-cni-daemon"
service: "{{ zun_services[service_name] }}"
become: true
command: "docker cp {{ service.container_name }}:/opt/loopback /opt/cni/bin/"
command: "{{ kolla_container_engine }} cp {{ service.container_name }}:/opt/loopback /opt/cni/bin/"
# NOTE(yoctozepto): it would be cleaner to listen only on image change
# but there is no such mechanism (yet) and container change should be
# good enough (better than including config change triggers)

View File

@ -71,6 +71,13 @@ workaround_ansible_issue_8743: yes
# Optionally change the path to sysctl.conf modified by Kolla Ansible plays.
#kolla_sysctl_conf_path: /etc/sysctl.conf
################
# Container engine
################
# Valid options are [ docker ]
# kolla_container_engine: docker
################
# Docker options
################