diff --git a/doc/source/roles/role-tripleo-time.rst b/doc/source/roles/role-tripleo-time.rst new file mode 100644 index 000000000..e3053d7a0 --- /dev/null +++ b/doc/source/roles/role-tripleo-time.rst @@ -0,0 +1,6 @@ +=================== +Role - tripleo-time +=================== + +.. ansibleautoplugin:: + :role: tripleo_ansible/roles/tripleo-time diff --git a/tripleo_ansible/roles/tripleo-time/defaults/main.yml b/tripleo_ansible/roles/tripleo-time/defaults/main.yml new file mode 100644 index 000000000..68cf77253 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/defaults/main.yml @@ -0,0 +1,34 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# All variables intended for modification should place placed in this file. + +tripleo_timezone: 'UTC' + +tripleo_ptp_slave_mode: 1 +tripleo_ptp_interfaces: ["{{ ansible_default_ipv4.interface }}"] +tripleo_ptp_transport: UDPv4 +tripleo_ptp_hardware_offload: false + +tripleo_ptp_packages: "{{ _tripleo_ptp_packages | default([]) }}" + +# The phc2sys interface can be user defined. If this option is undefined, a +# compatible interface will be chosen using the devices set in the device +# array `tripleo_ptp_interfaces`. +# +# To set the phc2sys interface use the following option. +# tripleo_phc_interface: eth0 diff --git a/tripleo_ansible/roles/tripleo-time/handlers/main.yml b/tripleo_ansible/roles/tripleo-time/handlers/main.yml new file mode 100644 index 000000000..eca853f8b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/handlers/main.yml @@ -0,0 +1,35 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Enable and start the ptp service + systemd: + name: ptp4l + state: started + enabled: true + +- name: Enable and start the phc2sys service + systemd: + name: phc2sys + state: restarted + enabled: true + +- name: Restart time services + service: + name: "{{ item }}" + state: restarted + with_items: + - rsyslog + - crond diff --git a/tripleo_ansible/roles/tripleo-time/meta/main.yml b/tripleo_ansible/roles/tripleo-time/meta/main.yml new file mode 100644 index 000000000..41b1cdaca --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/meta/main.yml @@ -0,0 +1,44 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +galaxy_info: + author: OpenStack + description: TripleO OpenStack Role -- tripleo-time + company: Red Hat + license: Apache-2.0 + min_ansible_version: 2.7 + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + platforms: + - name: Fedora + versions: + - 28 + - name: CentOS + versions: + - 7 + + galaxy_tags: + - tripleo + + +# List your role dependencies here, one per line. Be sure to remove the '[]' above, +# if you add dependencies to this list. +dependencies: [] diff --git a/tripleo_ansible/roles/tripleo-time/molecule/default/Dockerfile b/tripleo_ansible/roles/tripleo-time/molecule/default/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/molecule/default/Dockerfile @@ -0,0 +1,37 @@ +# Molecule managed +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi + +{% for pkg in item.easy_install | default([]) %} +# install pip for centos where there is no python-pip rpm in default repos +RUN easy_install {{ pkg }} +{% endfor %} + + +CMD ["sh", "-c", "while true; do sleep 10000; done"] diff --git a/tripleo_ansible/roles/tripleo-time/molecule/default/molecule.yml b/tripleo_ansible/roles/tripleo-time/molecule/default/molecule.yml new file mode 100644 index 000000000..d808d17ff --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/molecule/default/molecule.yml @@ -0,0 +1,68 @@ +--- +driver: + name: docker + +log: true + +platforms: + - name: centos7 + hostname: centos7 + image: centos:7 + dockerfile: Dockerfile + pkg_extras: python-setuptools cronie rsyslog + easy_install: + - pip + environment: &env + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + command: /sbin/init + tmpfs: + - /run + - /tmp + capabilities: + - ALL # CENT7 requires all due to the age of the software + volumes: + - /run/udev:/run/udev:ro + - /sys/fs/cgroup:/sys/fs/cgroup:ro + + - name: fedora28 + hostname: fedora28 + image: fedora:28 + dockerfile: Dockerfile + pkg_extras: python*-setuptools cronie rsyslog + environment: + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + command: /sbin/init + privileged: true + tmpfs: + - /run + - /tmp + capabilities: + - SYS_ADMIN + volumes: + - /run/udev:/run/udev:ro + - /sys/fs/cgroup:/sys/fs/cgroup:ro + +provisioner: + name: ansible + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + +scenario: + test_sequence: + - destroy + - create + - prepare + - converge + - verify + - destroy + +lint: + enabled: false + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/tripleo_ansible/roles/tripleo-time/molecule/default/playbook.yml b/tripleo_ansible/roles/tripleo-time/molecule/default/playbook.yml new file mode 100644 index 000000000..5bad75c09 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/molecule/default/playbook.yml @@ -0,0 +1,21 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + hosts: all + roles: + - role: "tripleo-time" diff --git a/tripleo_ansible/roles/tripleo-time/molecule/default/prepare.yml b/tripleo_ansible/roles/tripleo-time/molecule/default/prepare.yml new file mode 100644 index 000000000..ef85c3128 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/molecule/default/prepare.yml @@ -0,0 +1,21 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + roles: + - role: test_deps diff --git a/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/Dockerfile b/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/Dockerfile @@ -0,0 +1,37 @@ +# Molecule managed +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi + +{% for pkg in item.easy_install | default([]) %} +# install pip for centos where there is no python-pip rpm in default repos +RUN easy_install {{ pkg }} +{% endfor %} + + +CMD ["sh", "-c", "while true; do sleep 10000; done"] diff --git a/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/molecule.yml b/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/molecule.yml new file mode 100644 index 000000000..a750b2b65 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/molecule.yml @@ -0,0 +1,68 @@ +--- +driver: + name: docker + +log: true + +platforms: + - name: centos7 + hostname: centos7 + image: centos:7 + dockerfile: Dockerfile + pkg_extras: python-setuptools ntp + easy_install: + - pip + environment: &env + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + command: /sbin/init + tmpfs: + - /run + - /tmp + capabilities: + - ALL # CENT7 requires all due to the age of the software + volumes: + - /run/udev:/run/udev:ro + - /sys/fs/cgroup:/sys/fs/cgroup:ro + + - name: fedora28 + hostname: fedora28 + image: fedora:28 + dockerfile: Dockerfile + pkg_extras: python*-setuptools ntp + environment: + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + command: /sbin/init + privileged: true + tmpfs: + - /run + - /tmp + capabilities: + - SYS_ADMIN + volumes: + - /run/udev:/run/udev:ro + - /sys/fs/cgroup:/sys/fs/cgroup:ro + +provisioner: + name: ansible + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + +scenario: + test_sequence: + - destroy + - create + - prepare + - converge + - verify + - destroy + +lint: + enabled: false + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/playbook.yml b/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/playbook.yml new file mode 100644 index 000000000..1b96acf4d --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/playbook.yml @@ -0,0 +1,24 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + hosts: all + tasks: + - name: Run ntp stop + include_role: + name: tripleo-time + tasks_from: tripleo_ntp_stop.yml diff --git a/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/prepare.yml b/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/prepare.yml new file mode 100644 index 000000000..ee39e9c4a --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/molecule/ntp_stop/prepare.yml @@ -0,0 +1,27 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + roles: + - role: test_deps + post_tasks: + - name: Start ntpd + systemd: + name: ntpd + state: started + enabled: true diff --git a/tripleo_ansible/roles/tripleo-time/tasks/main.yml b/tripleo_ansible/roles/tripleo-time/tasks/main.yml new file mode 100644 index 000000000..c91b43926 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/tasks/main.yml @@ -0,0 +1,45 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# "tripleo-time" will search for and load any operating system variable file + +# found within the "vars/" path. If no OS files are found the task will skip. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - skip: true + files: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + +- name: Set timezone + timezone: + name: "{{ tripleo_timezone }}" + notify: + - Restart time services + +- name: Run ptp tasks + include_tasks: tripleo_ptp.yml + +- name: Run phc2sys tasks + include_tasks: tripleo_phc2sys.yml diff --git a/tripleo_ansible/roles/tripleo-time/tasks/tripleo_ntp_stop.yml b/tripleo_ansible/roles/tripleo-time/tasks/tripleo_ntp_stop.yml new file mode 100644 index 000000000..fb590dfa4 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/tasks/tripleo_ntp_stop.yml @@ -0,0 +1,32 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Check NTP service state + systemd: + name: ntpd + register: ntpd_service_state + failed_when: false + +- name: Stop NTP service + systemd: + name: ntpd + enabled: false + state: stopped + when: + - ntpd_service_state is success + - ((ntpd_service_state.status['SubState'] | lower) == 'running') or + ((ntpd_service_state.status['UnitFileState'] | lower) == 'enabled') diff --git a/tripleo_ansible/roles/tripleo-time/tasks/tripleo_phc2sys.yml b/tripleo_ansible/roles/tripleo-time/tasks/tripleo_phc2sys.yml new file mode 100644 index 000000000..35f202cdd --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/tasks/tripleo_phc2sys.yml @@ -0,0 +1,39 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Check for phc capabilities + command: "phc_ctl -q {{ item }}" + changed_when: false + failed_when: false + with_items: "{{ tripleo_ptp_interfaces }}" + register: device_capabilities + +- name: Validate hardware offload + set_fact: + tripleo_phc_interface: "{{ (device_capabilities.results | selectattr('rc', 'equalto', '0') | map(attribute='item') | list | first) | default('') }}" + when: + - tripleo_phc_interface is undefined + +- name: Create ptp service config + copy: + content: |- + OPTIONS="{{ ((tripleo_phc_interface | length) > 0) | ternary('-s' ~ tripleo_phc_interface ~ '-w', '-a -r') }}" + dest: /etc/sysconfig/phc2sys + when: + - tripleo_phc_interface + notify: + - Enable and start the phc2sys service diff --git a/tripleo_ansible/roles/tripleo-time/tasks/tripleo_ptp.yml b/tripleo_ansible/roles/tripleo-time/tasks/tripleo_ptp.yml new file mode 100644 index 000000000..360225c87 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/tasks/tripleo_ptp.yml @@ -0,0 +1,72 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Install ptp packages + package: + name: "{{ tripleo_ptp_packages }}" + state: present + notify: + - Enable and start the ptp service + +- name: Collect only facts returned by facter + setup: + gather_subset: + - network + +# NOTE(cloudnull): In the future, we could potentially revisit this once the Heat +# template for the "kernel" sysctl settings has been converted into +# an Ansible role and re-use the functionality of that. +# https://github.com/openstack/tripleo-heat-templates/blob/master/deployment/kernel/kernel-baremetal-puppet.yaml +- name: Enable multi-nic ptp + when: + - (tripleo_ptp_interfaces | length) > 1 + block: + - name: Relax rp filter + sysctl: + name: "net.ipv4.conf.{{ item }}.rp_filter" + value: 2 + sysctl_set: true + sysctl_file: /etc/sysctl.d/99-tripleo-ptp.conf + state: present + reload: true + with_items: "{{ tripleo_ptp_interfaces }}" + +- name: Check for hardware capabilities + command: "ethtool -T {{ item }}" + changed_when: false + failed_when: false + with_items: "{{ tripleo_ptp_interfaces }}" + register: device_capabilities + +- name: Validate hardware offload + set_fact: + tripleo_ptp_hardware_offload: "{{ (device_capabilities.results | map(attribute='rc') | list | sum) == 0 }}" + +- name: Create ptp config + template: + src: "ptp4l.conf.j2" + dest: /etc/ptp4l.conf + notify: + - Enable and start the ptp service + +- name: Create ptp service config + copy: + content: |- + OPTIONS="-f /etc/ptp4l.conf" + dest: /etc/sysconfig/ptp4l + notify: + - Enable and start the ptp service diff --git a/tripleo_ansible/roles/tripleo-time/templates/ptp4l.conf.j2 b/tripleo_ansible/roles/tripleo-time/templates/ptp4l.conf.j2 new file mode 100644 index 000000000..d36aef146 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/templates/ptp4l.conf.j2 @@ -0,0 +1,12 @@ +# {{ ansible_managed }} + +[global] +slaveOnly 1 +domainNumber {{ tripleo_ptp_slave_mode }} +time_stamping {{ (tripleo_ptp_hardware_offload | bool) | ternary('hardware', 'software') }} +network_transport {{ tripleo_ptp_transport }} +udp_ttl 1 + +{% for interface in tripleo_ptp_interfaces %} +[{{ interface }}] +{% endfor %} diff --git a/tripleo_ansible/roles/tripleo-time/vars/redhat.yml b/tripleo_ansible/roles/tripleo-time/vars/redhat.yml new file mode 100644 index 000000000..c90e06c93 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-time/vars/redhat.yml @@ -0,0 +1,21 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +_tripleo_ptp_packages: + - ethtool + - iproute + - linuxptp diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index b5fd21f20..2008b56f0 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -20,6 +20,7 @@ - tripleo-ansible-centos-7-molecule-tripleo-persist - tripleo-ansible-centos-7-molecule-tripleo-ceph-run-ansible - tripleo-ansible-centos-7-molecule-login-defs + - tripleo-ansible-centos-7-molecule-tripleo-time gate: jobs: - tripleo-ansible-centos-7-molecule-aide @@ -40,6 +41,7 @@ - tripleo-ansible-centos-7-molecule-tripleo-persist - tripleo-ansible-centos-7-molecule-tripleo-ceph-run-ansible - tripleo-ansible-centos-7-molecule-login-defs + - tripleo-ansible-centos-7-molecule-tripleo-time name: tripleo-ansible-molecule-jobs - job: files: @@ -173,3 +175,10 @@ parent: tripleo-ansible-centos-7-base vars: tripleo_role_name: login-defs +- job: + files: + - ^tripleo_ansible/roles/tripleo-time/.* + name: tripleo-ansible-centos-7-molecule-tripleo-time + parent: tripleo-ansible-centos-7-base + vars: + tripleo_role_name: tripleo-time