Create a time role
This change creates a role using the time content from THT[0]. This role will run through all of the tasks found within the THT file, and implements molecule tests coving the functionality. Test Matrix: - default - Runs through the role top to bottom, installing and configuring ptp. - ntp_stop - Sets up an environment and ensures we properly stop ntpd when directed to. [0] - https://github.com/openstack/tripleo-heat-templates/tree/master/deployment/time Story: 2006028 Task: 34653 Task: 34655 Task: 34656 Change-Id: I4c36c5058c901cb4ead5f781082e5f97014221cb Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
parent
7b6bd68569
commit
c1e098de6d
6
doc/source/roles/role-tripleo-time.rst
Normal file
6
doc/source/roles/role-tripleo-time.rst
Normal file
@ -0,0 +1,6 @@
|
||||
===================
|
||||
Role - tripleo-time
|
||||
===================
|
||||
|
||||
.. ansibleautoplugin::
|
||||
:role: tripleo_ansible/roles/tripleo-time
|
34
tripleo_ansible/roles/tripleo-time/defaults/main.yml
Normal file
34
tripleo_ansible/roles/tripleo-time/defaults/main.yml
Normal file
@ -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
|
35
tripleo_ansible/roles/tripleo-time/handlers/main.yml
Normal file
35
tripleo_ansible/roles/tripleo-time/handlers/main.yml
Normal file
@ -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
|
44
tripleo_ansible/roles/tripleo-time/meta/main.yml
Normal file
44
tripleo_ansible/roles/tripleo-time/meta/main.yml
Normal file
@ -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: []
|
@ -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"]
|
@ -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
|
@ -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"
|
@ -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
|
@ -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"]
|
@ -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
|
@ -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
|
@ -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
|
45
tripleo_ansible/roles/tripleo-time/tasks/main.yml
Normal file
45
tripleo_ansible/roles/tripleo-time/tasks/main.yml
Normal file
@ -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
|
@ -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')
|
39
tripleo_ansible/roles/tripleo-time/tasks/tripleo_phc2sys.yml
Normal file
39
tripleo_ansible/roles/tripleo-time/tasks/tripleo_phc2sys.yml
Normal file
@ -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
|
72
tripleo_ansible/roles/tripleo-time/tasks/tripleo_ptp.yml
Normal file
72
tripleo_ansible/roles/tripleo-time/tasks/tripleo_ptp.yml
Normal file
@ -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
|
12
tripleo_ansible/roles/tripleo-time/templates/ptp4l.conf.j2
Normal file
12
tripleo_ansible/roles/tripleo-time/templates/ptp4l.conf.j2
Normal file
@ -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 %}
|
21
tripleo_ansible/roles/tripleo-time/vars/redhat.yml
Normal file
21
tripleo_ansible/roles/tripleo-time/vars/redhat.yml
Normal file
@ -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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user