TripleO Ansible project repository. Contains playbooks for use with TripleO OpenStack deployments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
4.6KB

  1. ---
  2. # Copyright 2019 Red Hat, Inc.
  3. # All Rights Reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. # not use this file except in compliance with the License. You may obtain
  7. # a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. # License for the specific language governing permissions and limitations
  15. # under the License.
  16. - name: "Async container create/run"
  17. async: 300
  18. poll: 0
  19. register: create_async_results
  20. no_log: "{{ not (tripleo_container_manage_debug | bool) }}"
  21. loop: "{{ batched_container_data | haskey(attribute='action', reverse=True) }}"
  22. loop_control:
  23. loop_var: container_data
  24. podman_container:
  25. cap_add: "{{ lookup('dict', container_data).value.cap_add | default(omit) }}"
  26. cap_drop: "{{ lookup('dict', container_data).value.cap_drop | default(omit) }}"
  27. command: "{{ lookup('dict', container_data).value.command | default(omit) }}"
  28. conmon_pidfile: "/var/run/{{ lookup('dict', container_data).key }}.pid"
  29. cpu_shares: "{{ lookup('dict', container_data).value.cpu_shares | default(omit) | int }}"
  30. # cpuset_cpus: "{{ lookup('dict', container_data).value.cpuset_cpus | default(omit) }}"
  31. detach: "{{ lookup('dict', container_data).value.detach | default(true) }}"
  32. env: "{{ lookup('dict', container_data).value.environment | default(omit) }}"
  33. env_file: "{{ lookup('dict', container_data).value.env_file | default(omit) }}"
  34. etc_hosts: "{{ lookup('dict', container_data).value.extra_hosts | default({}) }}"
  35. group_add: "{{ lookup('dict', container_data).value.group_add | default(omit) }}"
  36. hostname: "{{ lookup('dict', container_data).value.hostname | default(omit) }}"
  37. image: "{{ lookup('dict', container_data).value.image }}"
  38. interactive: "{{ lookup('dict', container_data).value.interactive | default(false) }}"
  39. ipc: "{{ lookup('dict', container_data).value.ipc | default(omit) }}"
  40. label:
  41. config_id: "{{ tripleo_container_manage_config_id }}"
  42. container_name: "{{ lookup('dict', container_data).key }}"
  43. managed_by: tripleo_ansible
  44. config_data: "{{ container_data | to_json }}"
  45. log_driver: 'k8s-file'
  46. log_opt: "path={{ tripleo_container_manage_log_path }}/{{ lookup('dict', container_data).key }}.log"
  47. memory: "{{ lookup('dict', container_data).value.mem_limit | default(omit) }}"
  48. memory_swap: "{{ lookup('dict', container_data).value.mem_swappiness | default(omit) }}"
  49. name: "{{ lookup('dict', container_data).key }}"
  50. net: "{{ lookup('dict', container_data).value.net | default('none') }}"
  51. pid: "{{ lookup('dict', container_data).value.pid | default(omit) }}"
  52. privileged: "{{ lookup('dict', container_data).value.privileged | default(false) }}"
  53. rm: "{{ lookup('dict', container_data).value.remove | default(false) }}"
  54. security_opt: "{{ lookup('dict', container_data).value.security_opt | default(omit) }}"
  55. state: present
  56. stop_signal: "{{ lookup('dict', container_data).value.stop_signal | default(omit) }}"
  57. stop_timeout: "{{ lookup('dict', container_data).value.stop_grace_period | default(omit) | int }}"
  58. tty: "{{ lookup('dict', container_data).value.tty | default(false) }}"
  59. ulimit: "{{ lookup('dict', container_data).value.ulimit | default(omit) }}"
  60. user: "{{ lookup('dict', container_data).value.user | default(omit) }}"
  61. uts: "{{ lookup('dict', container_data).value.uts | default(omit) }}"
  62. volume: "{{ lookup('dict', container_data).value.volumes | default(omit) }}"
  63. volumes_from: "{{ lookup('dict', container_data).value.volumes_from | default([]) }}"
  64. - name: "Check podman create status"
  65. async_status:
  66. jid: "{{ create_async_result_item.ansible_job_id }}"
  67. loop: "{{ create_async_results.results }}"
  68. loop_control:
  69. loop_var: "create_async_result_item"
  70. register: create_async_poll_results
  71. until: create_async_poll_results.finished
  72. retries: 30
  73. when: not ansible_check_mode|bool
  74. # This fact will be used in systemd playbook to figure out if whether or not
  75. # a container managed by systemd needs to be restarted
  76. - name: "Create a list of containers which changed"
  77. set_fact:
  78. containers_changed: >-
  79. {{ create_async_results.results | selectattr('changed', 'equalto', true) |
  80. map(attribute='container_data') | list | list_of_keys }}
  81. - name: "Print the list of containers which changed"
  82. debug:
  83. var: containers_changed
  84. when: tripleo_container_manage_debug | bool