- name: Restart ODL
- when: systemd_installed.rc == 0
+ when: in_container.rc == 1
service:
name=opendaylight
state=restarted
- name: Start ODL
- when: systemd_installed.rc == 0
+ when: in_container.rc == 1
service:
name=opendaylight
state=started
- name: Stop ODL
- when: systemd_installed.rc == 0
+ when: in_container.rc == 1
service:
name=opendaylight
state=stopped
--- /dev/null
+---
+- name: Check if in a container
+ command: grep -q docker /proc/1/cgroup
+ failed_when: in_container.rc not in [0, 1]
+ changed_when: false
+ register: in_container
+++ /dev/null
----
-- name: Check if systemd is installed
- command: rpm -q systemd
- failed_when: systemd_installed.rc not in [0, 1]
- changed_when: false
- register: systemd_installed
---
-- include: is_systemd_installed.yml
+- include: in_container.yml
- name: Check if FirewallD service is running
command: systemctl is-active firewalld
failed_when: firewalld_status.stdout not in ['unknown', 'active']
changed_when: false
register: firewalld_status
- when: systemd_installed.rc == 0
+ when: in_container.rc == 1
- name: Open ODL NB REST port via FirewallD
- when: systemd_installed.rc == 0 and firewalld_status.stdout == 'active'
+ when: in_container.rc == 1 and firewalld_status.stdout == 'active'
firewalld:
port={{ nb_rest_port }}/tcp
state=enabled
---
-- include: is_systemd_installed.yml
+- include: in_container.yml
- include: start_odl_systemd_service.yml
- when: systemd_installed.rc == 0
+ when: in_container.rc == 1