Browse code

Use configure-swap from o-z-j

Use the generic role

Change-Id: I534ed0256b7dfe5bef4ab13ae57cd73c51e8bd15
Depends-On: I0e9c846ace7fac8a1340746c6818fba6ec963018

Ian Wienand authored on 2017/10/20 12:21:33
Showing 6 changed files
... ...
@@ -38,6 +38,8 @@
38 38
       - openstack/nova
39 39
       - openstack/requirements
40 40
       - openstack/swift
41
+    roles:
42
+      - zuul: openstack-infra/openstack-zuul-jobs
41 43
     timeout: 7200
42 44
     vars:
43 45
       devstack_localrc:
44 46
deleted file mode 100644
... ...
@@ -1,11 +0,0 @@
1
-Configure a swap partition
2
-
3
-Creates a swap partition on the ephemeral block device (the rest of which
4
-will be mounted on /opt).
5
-
6
-**Role Variables**
7
-
8
-.. zuul:rolevar:: configure_swap_size
9
-   :default: 8192
10
-
11
-   The size of the swap partition, in MiB.
12 1
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-configure_swap_size: 8192
2 1
deleted file mode 100644
... ...
@@ -1,110 +0,0 @@
1
-# Configure attached ephemeral devices for storage and swap
2
-
3
-- assert:
4
-    that:
5
-      - "ephemeral_device is defined"
6
-
7
-- name: Set partition names
8
-  set_fact:
9
-    swap_partition: "{{ ephemeral_device}}1"
10
-    opt_partition: "{{ ephemeral_device}}2"
11
-
12
-- name: Ensure ephemeral device is unmounted
13
-  become: yes
14
-  mount:
15
-    name: "{{ ephemeral_device }}"
16
-    state: unmounted
17
-
18
-- name: Get existing partitions
19
-  become: yes
20
-  parted:
21
-    device: "{{ ephemeral_device }}"
22
-    unit: MiB
23
-  register: ephemeral_partitions
24
-
25
-- name: Remove any existing partitions
26
-  become: yes
27
-  parted:
28
-    device: "{{ ephemeral_device }}"
29
-    number: "{{ item.num }}"
30
-    state: absent
31
-  with_items:
32
-    - "{{ ephemeral_partitions.partitions }}"
33
-
34
-- name: Create new disk label
35
-  become: yes
36
-  parted:
37
-    label: msdos
38
-    device: "{{ ephemeral_device }}"
39
-
40
-- name: Create swap partition
41
-  become: yes
42
-  parted:
43
-    device: "{{ ephemeral_device }}"
44
-    number: 1
45
-    state: present
46
-    part_start: '0%'
47
-    part_end: "{{ configure_swap_size }}MiB"
48
-
49
-- name: Create opt partition
50
-  become: yes
51
-  parted:
52
-    device: "{{ ephemeral_device }}"
53
-    number: 2
54
-    state: present
55
-    part_start: "{{ configure_swap_size }}MiB"
56
-    part_end: "100%"
57
-
58
-- name: Make swap on partition
59
-  become: yes
60
-  command: "mkswap {{ swap_partition }}"
61
-
62
-- name: Write swap to fstab
63
-  become: yes
64
-  mount:
65
-    path: none
66
-    src: "{{ swap_partition }}"
67
-    fstype: swap
68
-    opts: sw
69
-    passno: 0
70
-    dump: 0
71
-    state: present
72
-
73
-# XXX: does "parted" plugin ensure the partition is available
74
-# before moving on?  No udev settles here ...
75
-
76
-- name: Add all swap
77
-  become: yes
78
-  command: swapon -a
79
-
80
-- name: Create /opt filesystem
81
-  become: yes
82
-  filesystem:
83
-    fstype: ext4
84
-    dev: "{{ opt_partition }}"
85
-
86
-# Rackspace at least does not have enough room for two devstack
87
-# installs on the primary partition.  We copy in the existing /opt to
88
-# the new partition on the ephemeral device, and then overmount /opt
89
-# to there for the test runs.
90
-#
91
-# NOTE(ianw): the existing "mount" touches fstab.  There is currently (Sep2017)
92
-# work in [1] to split mount & fstab into separate parts, but for now we bundle
93
-# it into an atomic shell command
94
-# [1] https://github.com/ansible/ansible/pull/27174
95
-- name: Copy old /opt
96
-  become: yes
97
-  shell: |
98
-    mount {{ opt_partition }} /mnt
99
-    find /opt/ -mindepth 1 -maxdepth 1 -exec mv {} /mnt/ \;
100
-    umount /mnt
101
-
102
-# This overmounts any existing /opt
103
-- name: Add opt to fstab and mount
104
-  become: yes
105
-  mount:
106
-    path: /opt
107
-    src: "{{ opt_partition }}"
108
-    fstype: ext4
109
-    opts: noatime
110
-    state: mounted
111 1
deleted file mode 100644
... ...
@@ -1,63 +0,0 @@
1
-# On RAX hosts, we have a small root partition and a large,
2
-# unallocated ephemeral device attached at /dev/xvde
3
-- name: Set ephemeral device if /dev/xvde exists
4
-  when: ansible_devices["xvde"] is defined
5
-  set_fact:
6
-    ephemeral_device: "/dev/xvde"
7
-
8
-# On other providers, we have a device called "ephemeral0".
9
-#
10
-# NOTE(ianw): Once [1] is in our ansible (2.4 era?), we can figure
11
-# this out more directly by walking the device labels in the facts
12
-#
13
-# [1] https://github.com/ansible/ansible/commit/d46dd99f47c0ee5081d15bc5b741e9096d8bfd3e
14
-- name: Set ephemeral device by label
15
-  when: ephemeral_device is undefined
16
-  block:
17
-    - name: Get ephemeral0 device node
18
-      command: /sbin/blkid -L ephemeral0
19
-      register: ephemeral0
20
-      # If this doesn't exist, returns !0
21
-      ignore_errors: yes
22
-      changed_when: False
23
-
24
-    - name: Set ephemeral device if LABEL exists
25
-      when: "ephemeral0.rc == 0"
26
-      set_fact:
27
-        ephemeral_device: "{{ ephemeral0.stdout }}"
28
-
29
-# If we have ephemeral storage and we don't appear to have setup swap,
30
-# we will create a swap and move /opt to a large data partition there.
31
-- include: ephemeral.yaml
32
-  static: no
33
-  when:
34
-    - ephemeral_device is defined
35
-    - ansible_memory_mb['swap']['total'] | int + 10 <= configure_swap_size
36
-
37
-# If no ephemeral device and no swap, then we will setup some swap
38
-# space on the root device to ensure all hosts a consistent memory
39
-# environment.
40
-- include: root.yaml
41
-  static: no
42
-  when:
43
-    - ephemeral_device is undefined
44
-    - ansible_memory_mb['swap']['total'] | int + 10 <= configure_swap_size
45
-
46
-# ensure a standard level of swappiness.  Some platforms
47
-# (rax+centos7) come with swappiness of 0 (presumably because the
48
-# vm doesn't come with swap setup ... but we just did that above),
49
-# which depending on the kernel version can lead to the OOM killer
50
-# kicking in on some processes despite swap being available;
51
-# particularly things like mysql which have very high ratio of
52
-# anonymous-memory to file-backed mappings.
53
-#
54
-# This sets swappiness low; we really don't want to be relying on
55
-# cloud I/O based swap during our runs if we can help it
56
-- name: Set swappiness
57
-  become: yes
58
-  sysctl:
59
-    name: vm.swappiness
60
-    value: 30
61
-    state: present
62
-
63
-- debug:  var=ephemeral_device
64 1
deleted file mode 100644
... ...
@@ -1,63 +0,0 @@
1
-# If no ephemeral devices are available, use root filesystem
2
-
3
-- name: Calculate required swap
4
-  set_fact:
5
-    swap_required: "{{ configure_swap_size - ansible_memory_mb['swap']['total'] | int }}"
6
-
7
-- block:
8
-    - name: Get root filesystem
9
-      shell: df --output='fstype' /root | tail -1
10
-      register: root_fs
11
-
12
-    - name: Save root filesystem
13
-      set_fact:
14
-        root_filesystem: "{{ root_fs.stdout }}"
15
-
16
-    - debug: var=root_filesystem
17
-
18
-# Note, we don't use a sparse device to avoid wedging when disk space
19
-# and memory are both unavailable.
20
-
21
-# Cannot fallocate on filesystems like XFS, so use slower dd
22
-- name: Create swap backing file for non-EXT fs
23
-  when: '"ext" not in root_filesystem'
24
-  become: yes
25
-  command: dd if=/dev/zero of=/root/swapfile bs=1M count={{ swap_required }}
26
-  args:
27
-    creates: /root/swapfile
28
-
29
-- name: Create sparse swap backing file for EXT fs
30
-  when: '"ext" in root_filesystem'
31
-  become: yes
32
-  command: fallocate -l {{ swap_required }}M /root/swapfile
33
-  args:
34
-    creates: /root/swapfile
35
-
36
-- name: Ensure swapfile perms
37
-  become: yes
38
-  file:
39
-    path: /root/swapfile
40
-    owner: root
41
-    group: root
42
-    mode: 0600
43
-
44
-- name: Make swapfile
45
-  become: yes
46
-  command: mkswap /root/swapfile
47
-
48
-- name: Write swap to fstab
49
-  become: yes
50
-  mount:
51
-    path: none
52
-    src: /root/swapfile
53
-    fstype: swap
54
-    opts: sw
55
-    passno: 0
56
-    dump: 0
57
-    state: present
58
-
59
-- name: Add all swap
60
-  become: yes
61
-  command: swapon -a
62
-
63
-- debug: var=swap_required