Skip to content

Commit 8f59214

Browse files
authored
Merge pull request #605 from stackhpc/revert-cherry-pick
Revert "Cleaner split of kolla-ansible install and configure"
2 parents 4eb055d + 4216862 commit 8f59214

6 files changed

Lines changed: 53 additions & 108 deletions

File tree

ansible/install.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

ansible/roles/bootstrap/tasks/install.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

ansible/roles/bootstrap/tasks/main.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
---
2+
- block:
3+
- name: Testing privilege escalation
4+
raw: "true"
5+
become: true
6+
failed_when: false
7+
changed_when: false
8+
register: privilege_escalation_result
9+
10+
- name: Assert that we can escalate privileges
11+
assert:
12+
that:
13+
- privilege_escalation_result is success
14+
- '"password is required" not in privilege_escalation_result.stderr'
15+
fail_msg: >-
16+
Could not escalate privileges. You can either: set kayobe_control_host_become: true,
17+
set ansible_become_password, or set up passwordless sudo.
18+
when: kayobe_control_host_become | bool
19+
20+
- name: Include OS family-specific variables
21+
include_vars: "{{ ansible_facts.os_family }}.yml"
22+
23+
- name: Gather the package facts
24+
ansible.builtin.package_facts:
25+
manager: auto
26+
27+
- block:
28+
- name: Assert that all packages are installed if not using privilege escalation
29+
assert:
30+
that: missing_packages is falsy
31+
fail_msg: >-
32+
The following packages are missing from your system: {{ missing_packages | join(', ') }} and
33+
privilege escalation is disabled. Please get your system administator to install these packages
34+
or enable kayobe_control_host_become.
35+
when: not kayobe_control_host_become | bool
36+
37+
- name: Ensure required packages are installed
38+
package:
39+
name: "{{ bootstrap_package_dependencies }}"
40+
state: present
41+
cache_valid_time: "{{ apt_cache_valid_time if ansible_facts.os_family == 'Debian' else omit }}"
42+
update_cache: "{{ True if ansible_facts.os_family == 'Debian' else omit }}"
43+
become: True
44+
when: missing_packages is truthy
45+
vars:
46+
missing_packages: "{{ bootstrap_package_dependencies | difference(ansible_facts.packages.keys()) }}"
47+
148
- name: Check whether an SSH key exists
249
stat:
350
path: "{{ bootstrap_ssh_private_key_path }}"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---
2+
# NOTE: Use import_tasks here, since tags are not applied to tasks included via
3+
# include_tasks.
4+
- import_tasks: install.yml
5+
tags:
6+
- install
7+
28
- import_tasks: config.yml
39
tags:
410
- config

kayobe/cli/commands.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import os
1919
import re
2020
import sys
21-
import yaml
2221

2322
from cliff.command import Command
2423
from cliff.hooks import CommandHook
@@ -302,30 +301,13 @@ def get_parser(self, prog_name):
302301
group = parser.add_argument_group("Host Bootstrap")
303302
group.add_argument("--add-known-hosts", action='store_true',
304303
help="add SSH known hosts entries for each host")
305-
group.add_argument(
306-
"--install-only",
307-
action='store_true',
308-
default=yaml.safe_load(os.getenv("KAYOBE_INSTALL_ONLY", "false")),
309-
help=("only install dependencies "
310-
"(default from KAYOBE_INSTALL_ONLY env var)"),
311-
)
312304
return parser
313305

314306
def take_action(self, parsed_args):
315307
self.app.LOG.debug("Bootstrapping Kayobe Ansible control host")
316308
self.handle_kolla_tags_limits_deprecation(parsed_args)
317309
ansible.install_galaxy_roles(parsed_args)
318310
ansible.install_galaxy_collections(parsed_args)
319-
320-
playbooks = _build_playbook_list("install")
321-
self.run_kayobe_playbooks(parsed_args, playbooks, ignore_limit=True)
322-
323-
if parsed_args.install_only:
324-
self.app.LOG.debug("Skipping kolla-ansible installation and "
325-
"configuration generation due to "
326-
"--install-only")
327-
return
328-
329311
playbooks = _build_playbook_list("bootstrap")
330312
self.run_kayobe_playbooks(parsed_args, playbooks, ignore_limit=True)
331313

kayobe/tests/unit/cli/test_commands.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,6 @@ class TestCase(unittest.TestCase):
3838

3939
maxDiff = None
4040

41-
@mock.patch.dict(os.environ, {}, clear=True)
42-
def test_control_host_bootstrap_install_only_default_false(self):
43-
command = commands.ControlHostBootstrap(TestApp(), [])
44-
parser = command.get_parser("test")
45-
parsed_args = parser.parse_args([])
46-
self.assertFalse(parsed_args.install_only)
47-
48-
@mock.patch.dict(os.environ, {"KAYOBE_INSTALL_ONLY": "false"},
49-
clear=True)
50-
def test_control_host_bootstrap_install_only_default_false_from_env(self):
51-
command = commands.ControlHostBootstrap(TestApp(), [])
52-
parser = command.get_parser("test")
53-
parsed_args = parser.parse_args([])
54-
self.assertFalse(parsed_args.install_only)
55-
5641
@mock.patch.object(ansible, "install_galaxy_roles", autospec=True)
5742
@mock.patch.object(ansible, "install_galaxy_collections", autospec=True)
5843
@mock.patch.object(ansible, "passwords_yml_exists", autospec=True)
@@ -70,11 +55,6 @@ def test_control_host_bootstrap(self, mock_run, mock_passwords,
7055
mock_install_roles.assert_called_once_with(parsed_args)
7156
mock_install_collections.assert_called_once_with(parsed_args)
7257
expected_calls = [
73-
mock.call(
74-
mock.ANY,
75-
[utils.get_data_files_path("ansible", "install.yml")],
76-
ignore_limit=True,
77-
),
7858
mock.call(
7959
mock.ANY,
8060
[utils.get_data_files_path("ansible", "bootstrap.yml")],
@@ -109,11 +89,6 @@ def test_control_host_bootstrap_with_passwords(
10989
mock_install_roles.assert_called_once_with(parsed_args)
11090
mock_install_collections.assert_called_once_with(parsed_args)
11191
expected_calls = [
112-
mock.call(
113-
mock.ANY,
114-
[utils.get_data_files_path("ansible", "install.yml")],
115-
ignore_limit=True,
116-
),
11792
mock.call(
11893
mock.ANY,
11994
[utils.get_data_files_path("ansible", "bootstrap.yml")],

0 commit comments

Comments
 (0)