|
| 1 | +--- |
| 2 | +# Copyright 2024 Red Hat, Inc. |
| 3 | +# All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. You may obtain |
| 7 | +# a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | +# License for the specific language governing permissions and limitations |
| 15 | +# under the License. |
| 16 | + |
| 17 | +- name: Ensure /var/log/journal exists |
| 18 | + ansible.builtin.file: |
| 19 | + path: /var/log/journal |
| 20 | + state: directory |
| 21 | + mode: '0750' |
| 22 | + owner: root |
| 23 | + group: root |
| 24 | + setype: var_log_t |
| 25 | + become: true |
| 26 | + |
| 27 | +- name: Gather services facts |
| 28 | + ansible.builtin.service_facts: |
| 29 | + |
| 30 | +- name: Print cloud-init service status |
| 31 | + ansible.builtin.debug: |
| 32 | + var: ansible_facts.services["cloud-init.service"] |
| 33 | + |
| 34 | +- name: Check if cloud-init is disabled via kernel args |
| 35 | + ansible.builtin.lineinfile: |
| 36 | + path: /proc/cmdline |
| 37 | + line: "cloud-init=disabled" |
| 38 | + state: present |
| 39 | + check_mode: true |
| 40 | + register: cloud_init_vendor_disabled |
| 41 | + |
| 42 | +- name: Wait for cloud-init to finish, if enabled |
| 43 | + community.general.cloud_init_data_facts: |
| 44 | + filter: status |
| 45 | + register: res |
| 46 | + until: > |
| 47 | + res.cloud_init_data_facts.status.v1.stage is defined and |
| 48 | + not res.cloud_init_data_facts.status.v1.stage |
| 49 | + retries: 50 |
| 50 | + delay: 5 |
| 51 | + when: |
| 52 | + - not ansible_check_mode |
| 53 | + - ansible_facts.services["cloud-init.service"] is defined |
| 54 | + - ansible_facts.services["cloud-init.service"]["status"] != "not-found" |
| 55 | + - ansible_facts.services["cloud-init.service"]["state"] == "running" |
| 56 | + - ansible_facts.services["cloud-init.service"]["status"] == "enabled" |
| 57 | + - cloud_init_vendor_disabled is changed |
| 58 | + become: true |
| 59 | + |
| 60 | +- name: Execute bootstrap command |
| 61 | + ansible.builtin.import_tasks: bootstrap_command.yml |
0 commit comments