Commit 910d2148 authored by Alain Takoudjou's avatar Alain Takoudjou

vm-boostrap playbook: skip some tasks when playbook is well configured

parent 8e7d5a06
Pipeline #2099 skipped
......@@ -2,7 +2,16 @@
hosts: 127.0.0.1
connection: local
pre_tasks:
- name: Get mounted disk list
script: roles/vm-bootstrap/files/mounted_disk
register: vd_list
- name: resgister completed variable
stat: path=/etc/opt/vm-bootstrap-completed
register: ansible_completed
vars:
is_playbook_ok: "{{ ansible_completed.stat.exists }}"
logrotate_args:
- name: vm-bootstrap
path: /var/log/vm-bootstrap.log
......@@ -14,11 +23,6 @@
- create
- dateext
pre_tasks:
- name: Get mounted disk list
script: roles/vm-bootstrap/files/mounted_disk
register: vd_list
roles:
- { role: vm-bootstrap, startup_playbook_id: imt-vm-bootstrap.yml }
- ntp
......@@ -44,4 +48,9 @@
- { role: vm-disks, vd_disk: u, data_n: 12, when: vd_list.stdout.find("vdu") != -1 }
- role: logrotate
logrotate_scripts: "{{logrotate_args}}"
when: ansible_completed.stat.exists == False
tasks:
- name: Set tasks complete
file: path=/etc/opt/vm-bootstrap-completed state=touch
changed_when: false
......@@ -59,6 +59,7 @@
- name: Delete nameserver 8.8.8.8
lineinfile: dest=/etc/resolv.conf line="nameserver 8.8.8.8" state=absent
when: is_playbook_ok == "False"
- name: Turn off dhclient if it's running
shell: pkill dhclient
......
- include: uploadlog.yml
when: is_playbook_ok == "False"
- include: rerun.yml
when: is_playbook_ok == "False"
- name: Create /etc/opt dir
file: dest=/etc/opt mode=775 state=directory
......@@ -49,6 +51,7 @@
- include: hostname.yml
- include: user.yml
- include: sudo.yml
when: is_playbook_ok == "False"
- include: ssh.yml
- file: path=/opt/upgrader state=directory
......
......@@ -51,11 +51,12 @@
always_run: True
ignore_errors: True
changed_when: False
when: is_playbook_ok == "False"
- name: update /etc/ssh/sshd_config
lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (.*)" line="PermitRootLogin no" state=present
notify:
- restart ssh
- restart sshd
when: permitrootlogin.rc != 0
when: is_playbook_ok == "False" and permitrootlogin.rc != 0
---
- name: Remove playbook completed file
file: path=/etc/opt/vm-bootstrap-completed state=absent
- file: path=/opt/upgrader state=directory mode=0755
- stat: path=/opt/upgrader/current-upgrade-signature
......
......@@ -8,3 +8,4 @@
with_items:
- slapos
- nexedi
when: is_playbook_ok == "False"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment