main.yml 2.68 KB
Newer Older
1
---
2
  - file: path=/opt/upgrader state=directory mode=0755
3

4 5 6 7 8 9 10
  - stat: path=/opt/upgrader/playbook
    register: playbook

  - name: Download the playbook
    shell: /usr/local/bin/slapcache-download --destination=/opt/upgrader/archive.tar.gz
    when: playbook.stat.exists == False

Alain Takoudjou's avatar
Alain Takoudjou committed
11 12
  - file: path=/opt/upgrader/playbook state=directory mode=0755

13 14 15 16 17 18 19
  - name: Copy slapos.playbook
    unarchive: src=/opt/upgrader/archive.tar.gz dest=/opt/upgrader/playbook
    when: playbook.stat.exists == False

  - name: Set Startup Cron
    cron: name="Launch Startup with ansible" special_time=reboot job='cd /opt/upgrader/playbook && ansible-playbook imt-startup.yml -i hosts 2>>/opt/upgrader/startup.log >> /opt/upgrader/startup.log'

20 21 22
  - name: stat slapos.cfg file
    stat: path=/etc/opt/slapos/slapos.cfg
    register: slapos_cfg
23

24 25 26 27 28
  - name: update slapos.cfg configuration
    lineinfile: dest=/etc/opt/slapos/slapos.cfg regexp="{{ item.regexp }}" line="{{ item.line }}" backup=yes insertafter="^interface_name ="
    with_items:
      - { regexp: '^create_tap\s*=', line: 'create_tap = True' }
      - { regexp: '^tap_gateway_interface\s*=', line: 'tap_gateway_interface = re6stnet-tcp' }
29
      - { regexp: '^partition_amount\s*=', line: 'partition_amount = 125' }
30
      - { regexp: '^tap_ipv6\s*=', line: 'tap_ipv6 = False' }
31
    when: slapos_cfg.stat.exists == True and startup is not defined
32 33 34 35 36

  - name: update slapos.cfg configuration storage/network
    lineinfile: dest=/etc/opt/slapos/slapos.cfg regexp="{{ item.regexp }}" line="{{ item.line }}" backup=yes insertafter="^instance_root ="
    with_items:
     - { regexp: '^ipv4_global_network\s*=', line: 'ipv4_global_network = 10.32.0.0/13' }
37
     - { regexp: '^manager_list\s*=', line: 'manager_list = prerm' }
38
    when: slapos_cfg.stat.exists == True and startup is not defined
39

40 41
  - name: allow firewall in slapos.cfg configuration
    lineinfile: dest=/etc/opt/slapos/slapos.cfg regexp="{{ item.regexp }}" line="{{ item.line }}" backup=yes backrefs=true
42
    with_items:
43
      - { regexp: '^\[.*firewall\]$', line: '[firewall]' }
44 45 46 47 48
    when: slapos_cfg.stat.exists == True and startup is not defined

  - name: Run slapos format for update configs
    shell: "slapos node format -v --now"
    when: slapos_cfg.stat.exists == True and startup is not defined
49

50 51
  - name: Insert kvm module
    modprobe: name=kvm state=present
52

53 54
  - name: Insert kvm_intel module
    modprobe: name=kvm_intel state=present
55

56 57
  - name: Insert vhost-net module
    modprobe: name=vhost-net state=present
58

59 60
  - name: chmod 666 /dev/kvm
    file: path=/dev/kvm mode=0666
61

62 63
  - name: chmod 666 /dev/vhost-net
    file: path=/dev/vhost-net mode=0666
64

65 66
  - name: chmod 666 /dev/net/tun
    file: path=/dev/net/tun mode=0666
67

68