<commit_before>#
# Reboot overcloud nodes one-by-one.
#
- name: Overcloud Reboot
  hosts: overcloud_nodes:!unused
  gather_facts: false
  any_errors_fatal: true
  serial: 1
  tasks:
      # Temporerily disable ceph rebalance
      - name: temporerily disable ceph rebalance
        become: true
        command: "{{ item }}"
        when: "'ceph' in group_names"
        delegate_to: "{{ groups['controller']|first }}"
        with_items:
            - 'ceph osd set noout'
            - 'ceph osd set norebalance'

      # TODO(yprokule): figure out if we should migrate instances from computes ?
      - name: put node to standby mode
        command: |
            sudo pcs node standby --wait=300
        ignore_errors: True
        register: standby_node

      - name: reboot the node
        become: true
        shell: "sleep 5 && shutdown -r now"
        async: 1
        poll: 0
        ignore_errors: true

      - name: wait for node to go down
        command: ping -c1 {{ ansible_ssh_host }}
        register: node_down
        until: node_down.rc != 0
        retries: 60
        delay: 3
        ignore_errors: true
        delegate_to: hypervisor

      - block:
            - name: waiting for the node to be available
              wait_for:
                  port: 22
                  host: "{{ ansible_ssh_host }}"
                  search_regex: OpenSSH
                  delay: 60
                  timeout: 360
              delegate_to: localhost
              when: "'hypervisor' not in groups"

            - name: waiting for the node to be available
              become: no
              wait_for:
                  host: "{{ ansible_ssh_host }}"
                  port: 22
                  search_regex: OpenSSH
                  delay: 30
                  sleep: 15
                  timeout: 360
              delegate_to: hypervisor
              when: "'hypervisor' in groups"

      - name: check node is ssh-able
        shell: id || echo "NOT_READY"
        register: id_ssh
        until: "'{{ ansible_ssh_user }}' in id_ssh.stdout"
        retries: 20
        delay: 15

      # pacemaker managed services
      - name: unstandby pacemaker node
        become: true
        command: pcs node unstandby
        when: standby_node|succeeded

      - name: wait for pacemaker node to recover
        become: true
        shell: pcs status | grep 'Online:'
        register: pcs_status
        until: "'{{ inventory_hostname }}' in pcs_status.stdout"
        retries: 6
        delay: 5
        when: standby_node|succeeded

      - name: cleanup resource
        command: pcs resource cleanup {{ item }} --node {{ inventory_hostname }}
        ignore_errors: true
        with_items:
          - "{{ cleanup_services }}"
        when:
          - cleanup_services is defined
          - cleanup_services|default({})|length > 0
          - standby_node|succeeded

      - name: Check for any stopped pcs resources
        become: true
        shell: |
            pcs status | grep {{ item }} || /bin/true
        register: srv_status
        until: srv_status.stdout.find("{{ item }}") == -1
        retries: 36
        delay: 5
        with_items:
            - 'Stopped:'
        when:
            - standby_node|succeeded
            - "'{{ install.deployment.files | basename }}' == 'virt'"
<commit_msg>User 'become' when cleaning pacemaker resource.<commit_after>#
# Reboot overcloud nodes one-by-one.
#
- name: Overcloud Reboot
  hosts: overcloud_nodes:!unused
  gather_facts: false
  any_errors_fatal: true
  serial: 1
  tasks:
      # Temporerily disable ceph rebalance
      - name: temporerily disable ceph rebalance
        become: true
        command: "{{ item }}"
        when: "'ceph' in group_names"
        delegate_to: "{{ groups['controller']|first }}"
        with_items:
            - 'ceph osd set noout'
            - 'ceph osd set norebalance'

      # TODO(yprokule): figure out if we should migrate instances from computes ?
      - name: put node to standby mode
        command: |
            sudo pcs node standby --wait=300
        ignore_errors: True
        register: standby_node

      - name: reboot the node
        become: true
        shell: "sleep 5 && shutdown -r now"
        async: 1
        poll: 0
        ignore_errors: true

      - name: wait for node to go down
        command: ping -c1 {{ ansible_ssh_host }}
        register: node_down
        until: node_down.rc != 0
        retries: 60
        delay: 3
        ignore_errors: true
        delegate_to: hypervisor

      - block:
            - name: waiting for the node to be available
              wait_for:
                  port: 22
                  host: "{{ ansible_ssh_host }}"
                  search_regex: OpenSSH
                  delay: 60
                  timeout: 360
              delegate_to: localhost
              when: "'hypervisor' not in groups"

            - name: waiting for the node to be available
              become: no
              wait_for:
                  host: "{{ ansible_ssh_host }}"
                  port: 22
                  search_regex: OpenSSH
                  delay: 30
                  sleep: 15
                  timeout: 360
              delegate_to: hypervisor
              when: "'hypervisor' in groups"

      - name: check node is ssh-able
        shell: id || echo "NOT_READY"
        register: id_ssh
        until: "'{{ ansible_ssh_user }}' in id_ssh.stdout"
        retries: 20
        delay: 15

      # pacemaker managed services
      - name: unstandby pacemaker node
        become: true
        command: pcs node unstandby
        when: standby_node|succeeded

      - name: wait for pacemaker node to recover
        become: true
        shell: pcs status | grep 'Online:'
        register: pcs_status
        until: "'{{ inventory_hostname }}' in pcs_status.stdout"
        retries: 6
        delay: 5
        when: standby_node|succeeded

      - name: cleanup resource
        command: pcs resource cleanup {{ item }} --node {{ inventory_hostname }}
        become: true
        ignore_errors: true
        with_items:
          - "{{ cleanup_services }}"
        when:
          - cleanup_services is defined
          - cleanup_services|default({})|length > 0
          - standby_node|succeeded

      - name: Check for any stopped pcs resources
        become: true
        shell: |
            pcs status | grep {{ item }} || /bin/true
        register: srv_status
        until: srv_status.stdout.find("{{ item }}") == -1
        retries: 36
        delay: 5
        with_items:
            - 'Stopped:'
        when:
            - standby_node|succeeded
            - "'{{ install.deployment.files | basename }}' == 'virt'"

{'fraction_non_alphanumeric': 0.08356793599051711, 'fraction_numerical': 0.011557267743369388, 'mean_word_length': 1.5655644241733182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1781254', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1841, 'n_words': 571}