main.yml 2.53 KB
Newer Older
1
  - import_tasks: uploadlog.yml
2

3
  - import_tasks: rerun.yml
4

5 6 7 8
  - name: Create /etc/opt dir
    file: dest=/etc/opt mode=775 state=directory

  - name: Download configuration
9
    get_url: url=http://10.0.2.100/netconfig.sh dest=/etc/opt/netconfig.sh mode=755 force=yes
10 11 12 13 14 15
    ignore_errors: True

  - name: stat /etc/opt/netconfig.sh
    stat: path=/etc/opt/netconfig.sh
    register: netconfig_file

16 17
  - name: create cronjob for netconfig.sh at boot time
    cron:
18
      name: "call netconfig.sh at reboot (need to be called twice to work, until https://lab.nexedi.com/nexedi/slapos/commit/07439e2e6a8c39430d5be84ff3d77d2aae4d99c6 is used)"
19
      special_time: reboot
20
      job: "/etc/opt/netconfig.sh ; /etc/opt/netconfig.sh"
21 22 23
    when: netconfig_file.stat.exists == True

  - name: call netconfig.sh
24
    command: /etc/opt/netconfig.sh ; /etc/opt/netconfig.sh
25 26 27
    when: netconfig_file.stat.exists == True
    ignore_errors: True

28 29 30 31 32 33 34 35 36
  - name: Download cluster.hash
    get_url: url=http://10.0.2.100/cluster.hash dest=/etc/opt/cluster.hash mode=644
    ignore_errors: True

  - name: stat cluster.hash
    stat: path=/etc/opt/cluster.hash
    register: cluster_hash

  - name: get upgrade file if exists
37
    uri: url="{{ lookup('file', '/etc/opt/cluster.hash') }}/data" validate_certs=no status_code=200,304 return_content=yes
38 39
    when: cluster_hash.stat.exists == True
    ignore_errors: True
40
    register: upgrade_needed
41

42 43 44 45
  - import_tasks: network.yml
  - import_tasks: hostname.yml
  - import_tasks: user.yml
  - import_tasks: ssh.yml
46

47
  - name: Enable hotplugged CPU and Memory automatically
48
    lineinfile: dest=/etc/udev/rules.d/99-hotplug-cpu-mem.rules state=present create=yes line="{{ item }}"
49
    with_items:
50 51
      - "SUBSYSTEM==\"cpu\",ACTION==\"add\",RUN+=\"/bin/sh -c '[ ! -e /sys$devpath/online ] || echo 1 > /sys$devpath/online'\""
      - "SUBSYSTEM==\"memory\",ACTION==\"add\",RUN+=\"/bin/sh -c '[ ! -e /sys$devpath/online ] || echo online > /sys$devpath/state'\""
52
    when: ansible_distribution == "Ubuntu" or (ansible_distribution == "Debian" and ansible_distribution_major_version|int > 8)
53

54
  - file: path=/opt/upgrader state=directory 
55

56 57 58
  - stat: path=/opt/upgrader/last-upgrade
    register: last_upgrade

59 60
  - name: Setup initial last upgrade timestamps
    shell: echo 1 > /opt/upgrader/last-upgrade
61 62
    when: last_upgrade.stat.exists == False

63 64 65
  - include_tasks: upgrader.yml
    vars:
      upgrade_after: "{{ upgrade_needed.content }}"
66
    when: upgrade_needed.status in [200, 304] and (upgrade_needed.content|int > lookup('file', '/opt/upgrader/last-upgrade')|int)