blob: 6f475e4725cb490a95fc485991d38ac07e9e838d [file] [log] [blame]
Hyunsun Moone4848342020-02-16 04:28:55 -08001# Copyright 2020-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15---
16- name: Run "apt update"
17 apt:
18 update_cache: yes
19
20- name: Install ntp
Hyunsun Moon6c6db952020-03-04 20:50:51 -080021 apt:
22 name: ntp
23 state: present
Hyunsun Moone4848342020-02-16 04:28:55 -080024 when: ntp_enabled | bool
25 tags: ntp
26
27- name: Configure ntp file
Hyunsun Moon6c6db952020-03-04 20:50:51 -080028 template:
29 src: etc/ntp.conf.j2
30 dest: /etc/ntp.conf
Hyunsun Moone4848342020-02-16 04:28:55 -080031 when: ntp_enabled | bool
32 notify: restart ntp
33 tags: ntp
34
35- name: Start the ntp service
Hyunsun Moon6c6db952020-03-04 20:50:51 -080036 service:
37 name: ntp
38 state: started
39 enabled: yes
Hyunsun Moone4848342020-02-16 04:28:55 -080040 when: ntp_enabled | bool
41 tags: ntp
42
43- name: Set timezone to {{ ntp_timezone }}
44 timezone:
45 name: "{{ ntp_timezone }}"
46 when: ntp_enabled | bool
47 tags: ntp
48
49- name: Remove swapfile from /etc/fstab
50 mount:
51 name: "{{ item }}"
52 fstype: swap
53 state: absent
54 with_items:
55 - swap
56 - none
57 tags: swapoff
58
59- name: Check if swap is enabled
60 command: /sbin/swapon -s
61 register: swapon
62 changed_when: no
63 tags: swapoff
64
65- name: Disable swap
66 command: /sbin/swapoff -a
67 when: swapon.stdout
68 tags: swapoff
69
70- name: Add internal service domains to /etc/hosts
71 become: yes
72 lineinfile:
73 path: /etc/hosts
74 line: "{{ item['ip'] }}\t\t{{ item['name'] }}"
75 state: present
76 with_items: "{{ etc_hosts_entries }}"
77 tags: etc-hosts