blob: b0b2bfaa8d7ed02905723706fff242d34c0f2725 [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
21 apt: name=ntp state=present
22 when: ntp_enabled | bool
23 tags: ntp
24
25- name: Configure ntp file
26 template: src=etc/ntp.conf.j2 dest=/etc/ntp.conf
27 when: ntp_enabled | bool
28 notify: restart ntp
29 tags: ntp
30
31- name: Start the ntp service
32 service: name=ntp state=started enabled=yes
33 when: ntp_enabled | bool
34 tags: ntp
35
36- name: Set timezone to {{ ntp_timezone }}
37 timezone:
38 name: "{{ ntp_timezone }}"
39 when: ntp_enabled | bool
40 tags: ntp
41
42- name: Remove swapfile from /etc/fstab
43 mount:
44 name: "{{ item }}"
45 fstype: swap
46 state: absent
47 with_items:
48 - swap
49 - none
50 tags: swapoff
51
52- name: Check if swap is enabled
53 command: /sbin/swapon -s
54 register: swapon
55 changed_when: no
56 tags: swapoff
57
58- name: Disable swap
59 command: /sbin/swapoff -a
60 when: swapon.stdout
61 tags: swapoff
62
63- name: Add internal service domains to /etc/hosts
64 become: yes
65 lineinfile:
66 path: /etc/hosts
67 line: "{{ item['ip'] }}\t\t{{ item['name'] }}"
68 state: present
69 with_items: "{{ etc_hosts_entries }}"
70 tags: etc-hosts