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

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

parent 8e7d5a06
Pipeline #2098 skipped
...@@ -2,7 +2,16 @@ ...@@ -2,7 +2,16 @@
hosts: 127.0.0.1 hosts: 127.0.0.1
connection: local 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: vars:
is_playbook_ok: "{{ ansible_completed.stat.exists }}"
logrotate_args: logrotate_args:
- name: vm-bootstrap - name: vm-bootstrap
path: /var/log/vm-bootstrap.log path: /var/log/vm-bootstrap.log
...@@ -14,11 +23,6 @@ ...@@ -14,11 +23,6 @@
- create - create
- dateext - dateext
pre_tasks:
- name: Get mounted disk list
script: roles/vm-bootstrap/files/mounted_disk
register: vd_list
roles: roles:
- { role: vm-bootstrap, startup_playbook_id: imt-vm-bootstrap.yml } - { role: vm-bootstrap, startup_playbook_id: imt-vm-bootstrap.yml }
- ntp - ntp
...@@ -44,4 +48,9 @@ ...@@ -44,4 +48,9 @@
- { role: vm-disks, vd_disk: u, data_n: 12, when: vd_list.stdout.find("vdu") != -1 } - { role: vm-disks, vd_disk: u, data_n: 12, when: vd_list.stdout.find("vdu") != -1 }
- role: logrotate - role: logrotate
logrotate_scripts: "{{logrotate_args}}" 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 @@ ...@@ -59,6 +59,7 @@
- name: Delete nameserver 8.8.8.8 - name: Delete nameserver 8.8.8.8
lineinfile: dest=/etc/resolv.conf line="nameserver 8.8.8.8" state=absent 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 - name: Turn off dhclient if it's running
shell: pkill dhclient shell: pkill dhclient
......
- include: uploadlog.yml - include: uploadlog.yml
when: is_playbook_ok == "False"
- include: rerun.yml - include: rerun.yml
when: is_playbook_ok == "False"
- name: Create /etc/opt dir - name: Create /etc/opt dir
file: dest=/etc/opt mode=775 state=directory file: dest=/etc/opt mode=775 state=directory
...@@ -49,6 +51,7 @@ ...@@ -49,6 +51,7 @@
- include: hostname.yml - include: hostname.yml
- include: user.yml - include: user.yml
- include: sudo.yml - include: sudo.yml
when: is_playbook_ok == "False"
- include: ssh.yml - include: ssh.yml
- file: path=/opt/upgrader state=directory - file: path=/opt/upgrader state=directory
......
...@@ -51,11 +51,12 @@ ...@@ -51,11 +51,12 @@
always_run: True always_run: True
ignore_errors: True ignore_errors: True
changed_when: False changed_when: False
when: is_playbook_ok == "False"
- name: update /etc/ssh/sshd_config - name: update /etc/ssh/sshd_config
lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (.*)" line="PermitRootLogin no" state=present lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (.*)" line="PermitRootLogin no" state=present
notify: notify:
- restart ssh - restart ssh
- restart sshd - 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 - file: path=/opt/upgrader state=directory mode=0755
- stat: path=/opt/upgrader/current-upgrade-signature - stat: path=/opt/upgrader/current-upgrade-signature
......
...@@ -7,4 +7,5 @@ ...@@ -7,4 +7,5 @@
user: name={{ item }} state=absent user: name={{ item }} state=absent
with_items: with_items:
- slapos - slapos
- nexedi - nexedi
\ No newline at end of file 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