Skip to content

Commit 561005f

Browse files
committed
Makefile: use inventory from ansible.cfg
We can define the Ansible inventory via ansible.cfg inventory variable. Make use of it and remove all the -i/--inventory arguments in all the ansible-playbook calls. Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
1 parent 75bdf9d commit 561005f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+234
-229
lines changed

Makefile

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ include Makefile.subtrees
1515

1616
export KDEVOPS_EXTRA_VARS ?= extra_vars.yaml
1717
export KDEVOPS_PLAYBOOKS_DIR := playbooks
18-
export KDEVOPS_HOSTFILE ?= hosts
1918
export KDEVOPS_NODES :=
2019
export KDEVOPS_VAGRANT :=
2120
export PYTHONUNBUFFERED=1
@@ -75,8 +74,7 @@ CFLAGS += $(INCLUDES)
7574

7675
ANSIBLE_EXTRA_ARGS += kdevops_version='$(PROJECTRELEASE)'
7776

78-
export KDEVOPS_HOSTS_TEMPLATE := $(KDEVOPS_HOSTFILE).j2
79-
export KDEVOPS_HOSTS := $(KDEVOPS_HOSTFILE)
77+
export KDEVOPS_HOSTS_TEMPLATE := hosts.j2
8078

8179
LOCAL_DEVELOPMENT_ARGS :=
8280
ifeq (y,$(CONFIG_NEEDS_LOCAL_DEVELOPMENT_PATH))
@@ -194,8 +192,7 @@ include scripts/gen-nodes.Makefile
194192

195193
PHONY += ansible.cfg
196194
ansible.cfg:
197-
@$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
198-
--inventory localhost, \
195+
@$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
199196
$(KDEVOPS_PLAYBOOKS_DIR)/ansible_cfg.yml \
200197
--extra-vars=@./.extra_vars_auto.yaml
201198

@@ -223,17 +220,15 @@ ifneq (,$(KDEVOPS_BRING_UP_DEPS))
223220
include scripts/bringup.Makefile
224221
endif
225222

226-
DEFAULT_DEPS += $(KDEVOPS_HOSTS)
227-
$(KDEVOPS_HOSTS): .config ansible.cfg $(KDEVOPS_HOSTS_TEMPLATE)
228-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
229-
--inventory localhost, \
223+
DEFAULT_DEPS += inventory
224+
inventory: .config ansible.cfg $(KDEVOPS_HOSTS_TEMPLATE)
225+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
230226
$(KDEVOPS_PLAYBOOKS_DIR)/gen_hosts.yml \
231227
--extra-vars=@./extra_vars.yaml
232228

233229
DEFAULT_DEPS += $(KDEVOPS_NODES)
234230
$(KDEVOPS_NODES) $(KDEVOPS_VAGRANT): .config ansible.cfg $(KDEVOPS_NODES_TEMPLATE)
235-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
236-
--inventory localhost, \
231+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
237232
$(KDEVOPS_PLAYBOOKS_DIR)/gen_nodes.yml \
238233
--extra-vars=@./extra_vars.yaml
239234

@@ -259,7 +254,7 @@ mrproper:
259254
$(Q)rm -f terraform/*/terraform.tfvars
260255
$(Q)rm -rf terraform/*/.terraform
261256
$(Q)rm -f $(KDEVOPS_NODES)
262-
$(Q)rm -f $(KDEVOPS_HOSTFILE) $(KDEVOPS_MRPROPER)
257+
$(Q)rm -f $(CONFIG_ANSIBLE_CFG_INVENTORY) $(KDEVOPS_MRPROPER)
263258
$(Q)rm -f .config .config.old extra_vars.yaml $(KCONFIG_YAMLCFG)
264259
$(Q)rm -f ansible.cfg
265260
$(Q)rm -f playbooks/secret.yml $(KDEVOPS_EXTRA_ADDON_DEST)

Makefile.btrfs_progs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ BTRFS_PROGS_SETUP_ARGS += btrfs_progs_build=True
55

66
PHONY += btrfs-progs
77
btrfs-progs: $(KDEVOPS_NODES)
8-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \
9-
$(KDEVOPS_HOSTFILE) $(KDEVOPS_PLAYBOOKS_DIR)/btrfs-progs.yml \
8+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
9+
$(KDEVOPS_PLAYBOOKS_DIR)/btrfs-progs.yml \
1010
--extra-vars=$(BTRFS_PROGS_SETUP_ARGS) $(LIMIT_HOSTS)
1111

1212
btrfs-progs-help-menu:

Makefile.build_qemu

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,25 @@ QEMU_BUILD_SETUP_ARGS += qemu_target="ppc64-softmmu"
2020
endif
2121

2222
qemu: $(KDEVOPS_EXTRA_VARS)
23-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
24-
--inventory localhost, \
23+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
2524
$(KDEVOPS_PLAYBOOKS_DIR)/build_qemu.yml \
2625
--extra-vars=@./extra_vars.yaml
2726
PHONY += qemu
2827

2928
qemu-install: $(KDEVOPS_EXTRA_VARS)
30-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
31-
--inventory localhost, \
29+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
3230
$(KDEVOPS_PLAYBOOKS_DIR)/build_qemu.yml \
3331
--extra-vars=@./extra_vars.yaml --tags vars,install
3432
PHONY += qemu-install
3533

3634
qemu-configure: $(KDEVOPS_EXTRA_VARS)
37-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
38-
--inventory localhost, \
35+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
3936
$(KDEVOPS_PLAYBOOKS_DIR)/build_qemu.yml \
4037
--extra-vars=@./extra_vars.yaml --tags vars,configure
4138
PHONY += qemu-configure
4239

4340
qemu-build: $(KDEVOPS_EXTRA_VARS)
44-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
45-
--inventory localhost, \
41+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
4642
$(KDEVOPS_PLAYBOOKS_DIR)/build_qemu.yml \
4743
--extra-vars=@./extra_vars.yaml --tags vars,build
4844
PHONY += qemu-build

Makefile.hypervisor-tunings

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ HYPERVISOR_TUNING_ARGS += hypervisor_tunning_zswap_max_pool_percent=$(ZSWAP_MAX_
1414
endif
1515

1616
kdevops_hypervisor_tunning: $(KDEVOPS_EXTRA_VARS)
17-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
18-
--inventory localhost, \
17+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
1918
$(KDEVOPS_PLAYBOOKS_DIR)/hypervisor-tuning.yml \
2019
--extra-vars=@./extra_vars.yaml
2120
PHONY += kdevops_hypervisor_tunning

Makefile.kdevops

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,22 @@
22
# allow your project to define these and just include this file.
33
KDEVOPS_TERRAFORM_DIR ?= terraform
44
KDEVOPS_PLAYBOOKS_DIR ?= playbooks
5-
KDEVOPS_HOSTFILE ?= hosts
65
KDEVOPS_LOCAL_WORK :=
76

87
kdevops_all: kdevops_deps
98
PHONY := kdevops_all
109

1110
kdevops_terraform_deps:
12-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
13-
--inventory localhost, \
11+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
1412
$(KDEVOPS_PLAYBOOKS_DIR)/install_terraform.yml
1513
PHONY += kdevops_terraform_deps
1614

1715
kdevops_install_libvirt:
18-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
19-
--inventory localhost, \
16+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
2017
$(KDEVOPS_PLAYBOOKS_DIR)/libvirt_user.yml -e "skip_configuration=True"
2118

2219
kdevops_configure_libvirt:
23-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
24-
--inventory localhost, \
20+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
2521
$(KDEVOPS_PLAYBOOKS_DIR)/libvirt_user.yml -e "skip_install=True" \
2622
-e 'running_user=$(USER)'
2723

@@ -33,23 +29,20 @@ PHONY += kdevops_vagrant_deps
3329
KDEVOPS_VAGRANT_WORK := kdevops_vagrant_deps
3430

3531
kdevops_vagrant_boxes:
36-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
37-
--inventory localhost, \
32+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
3833
$(KDEVOPS_PLAYBOOKS_DIR)/install_vagrant_boxes.yml
3934
PHONY += kdevops_vagrant_boxes
4035
KDEVOPS_VAGRANT_WORK += kdevops_vagrant_boxes
4136

4237
kdevops_verify_libvirt_user:
43-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
44-
--inventory localhost, \
38+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
4539
$(KDEVOPS_PLAYBOOKS_DIR)/libvirt_user.yml -e "only_verify_user=True"
4640

4741
PHONY += kdevops_verify_libvirt_user
4842
KDEVOPS_VAGRANT_WORK += kdevops_verify_libvirt_user
4943

5044
kdevops_libvirt_storage_pool_create:
51-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
52-
--inventory localhost, \
45+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
5346
$(KDEVOPS_PLAYBOOKS_DIR)/libvirt_storage_pool_create.yml
5447

5548
PHONY += kdevops_libvirt_storage_pool_create

Makefile.linux-mirror

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ endif
2525
MIRROR_CODE := $(TOPDIR)/playbooks/roles/linux-mirror/linux-mirror-systemd/
2626

2727
kdevops_linux_mirror: $(KDEVOPS_EXTRA_VARS)
28-
$(Q)ansible-playbook --connection=local \
29-
--inventory localhost, \
28+
$(Q)ansible-playbook \
3029
--tags vars,mirror \
3130
$(KDEVOPS_PLAYBOOKS_DIR)/linux-mirror.yml \
3231
--extra-vars=@./extra_vars.yaml
@@ -37,8 +36,7 @@ mirror: $(KDEVOPS_EXTRA_VARS) kdevops_linux_mirror
3736
PHONY += mirror
3837

3938
mirror-status: $(KDEVOPS_EXTRA_VARS)
40-
$(Q)ansible-playbook --connection=local \
41-
--inventory localhost, \
39+
$(Q)ansible-playbook \
4240
--tags vars,mirror-status \
4341
$(KDEVOPS_PLAYBOOKS_DIR)/linux-mirror.yml \
4442
--extra-vars=@./extra_vars.yaml

Makefile.postfix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ POSTFIX_SETUP_ARGS += postfix_relay_host_setup=True
77
POSTFIX_SETUP_ARGS += postfix_relay_host=$(POSTFIX_RELAY_HOST)
88

99
kdevops_postfix_setup_relay: $(KDEVOPS_EXTRA_VARS)
10-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
11-
--inventory localhost, \
10+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
1211
$(KDEVOPS_PLAYBOOKS_DIR)/postfix_relay_host.yml \
1312
--extra-vars=@./extra_vars.yaml
1413
PHONY += kdevos_postfix_setup_relay

playbooks/roles/gen_hosts/defaults/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ hosts_type_generic: True
66
hosts_type_fs: False
77
hosts_type_block: False
88

9-
kdevops_hosts: "hosts"
109
kdevops_hosts_template: "hosts.in"
1110
kdevops_playbooks_dir: "/dev/null"
1211
kdevops_genhosts_templates_dir: "/dev/null"

playbooks/roles/gen_hosts/tasks/main.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@
1818
command: "id -g -n"
1919
register: my_group
2020

21-
- name: Check if the file {{ kdevops_hosts }} exists already
21+
- name: Check if the inventory file exists already
2222
stat:
23-
path: "{{ topdir_path }}/{{ kdevops_hosts }}"
23+
path: "{{ ansible_cfg_inventory }}"
2424
register: kdevops_hosts_dest
2525

26-
- name: Ensure proper permission on the file {{ kdevops_hosts }}
26+
- name: Ensure proper permission on the inventory file
2727
become: yes
2828
become_flags: 'su - -c'
2929
become_method: sudo
3030
file:
31-
path: "{{ topdir_path }}/{{ kdevops_hosts }}"
31+
path: "{{ ansible_cfg_inventory }}"
3232
owner: "{{ my_user.stdout }}"
3333
group: "{{ my_group.stdout }}"
3434
when:
3535
- kdevops_hosts_dest.stat.exists
3636

37-
- name: Verify Ansible host template file exists {{ kdevops_hosts_template_full_path }}
37+
- name: Verify Ansible inventory template file exists
3838
stat:
3939
path: "{{ kdevops_hosts_template_full_path }}"
4040
register: ansible_hosts_template
@@ -56,23 +56,23 @@
5656
when:
5757
- is_fstests
5858

59-
- name: Generate the Ansible hosts file
59+
- name: Generate the Ansible inventory file
6060
tags: [ 'hosts' ]
6161
template:
6262
src: "{{ kdevops_hosts_template }}"
63-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
63+
dest: "{{ ansible_cfg_inventory }}"
6464
force: yes
6565
trim_blocks: True
6666
lstrip_blocks: True
6767
when:
6868
- not kdevops_workflows_dedicated_workflow
6969
- ansible_hosts_template.stat.exists
7070

71-
- name: Generate the Ansible hosts file for dedicated cxl work
71+
- name: Generate the Ansible inventory file for dedicated cxl work
7272
tags: [ 'hosts' ]
7373
template:
7474
src: "{{ kdevops_hosts_template }}"
75-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
75+
dest: "{{ anisble_cfg_inventory }}"
7676
force: yes
7777
trim_blocks: True
7878
lstrip_blocks: True
@@ -81,11 +81,11 @@
8181
- kdevops_workflow_enable_cxl
8282
- ansible_hosts_template.stat.exists
8383

84-
- name: Generate the Ansible hosts file for dedicated pynfs work
84+
- name: Generate the Ansible inventory file for dedicated pynfs work
8585
tags: [ 'hosts' ]
8686
template:
8787
src: "{{ kdevops_hosts_template }}"
88-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
88+
dest: "{{ ansible_cfg_inventory }}"
8989
force: yes
9090
trim_blocks: True
9191
lstrip_blocks: True
@@ -94,13 +94,13 @@
9494
- kdevops_workflow_enable_pynfs
9595
- ansible_hosts_template.stat.exists
9696

97-
- name: Generate the Ansible hosts file for dedicated gitr workflow
97+
- name: Generate the Ansible inventory file for dedicated gitr workflow
9898
tags: [ 'hosts' ]
9999
vars:
100100
gitr_enabled_hosts: "{{ gitr_enabled_test_groups|ansible.builtin.split }}"
101101
template:
102102
src: "{{ kdevops_hosts_template }}"
103-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
103+
dest: "{{ ansible_cfg_inventory }}"
104104
force: true
105105
trim_blocks: true
106106
lstrip_blocks: true
@@ -109,13 +109,13 @@
109109
- kdevops_workflow_enable_gitr
110110
- ansible_hosts_template.stat.exists
111111

112-
- name: Generate an Ansible hosts file for a dedicated ltp workflow
112+
- name: Generate an Ansible inventory file for a dedicated ltp workflow
113113
tags: [ 'hosts' ]
114114
vars:
115115
ltp_enabled_hosts: "{{ ltp_enabled_test_groups|ansible.builtin.split }}"
116116
ansible.builtin.template:
117117
src: "{{ kdevops_hosts_template }}"
118-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
118+
dest: "{{ ansible_cfg_inventory }}"
119119
force: yes
120120
trim_blocks: True
121121
lstrip_blocks: True
@@ -124,13 +124,13 @@
124124
- kdevops_workflow_enable_ltp
125125
- ansible_hosts_template.stat.exists
126126

127-
- name: Generate the Ansible hosts file for dedicated nfstest workflow
127+
- name: Generate the Ansible inventory file for dedicated nfstest workflow
128128
tags: [ 'hosts' ]
129129
vars:
130130
nfstest_enabled_hosts: "{{ nfstest_enabled_test_groups | ansible.builtin.split }}"
131131
template:
132132
src: "{{ kdevops_hosts_template }}"
133-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
133+
dest: "{{ ansible_cfg_inventory }}"
134134
force: true
135135
trim_blocks: true
136136
lstrip_blocks: true
@@ -183,7 +183,7 @@
183183
- ansible_hosts_template.stat.exists
184184
- item.changed
185185

186-
- name: Generate the Ansible hosts file for a dedicated fstests setup
186+
- name: Generate the Ansible inventory file for a dedicated fstests setup
187187
tags: [ 'hosts' ]
188188
vars:
189189
fs_config_data: "{{ lookup('file', fs_config_path) }}"
@@ -194,7 +194,7 @@
194194
sections: "{{ sections_replace_underscore | replace(\"'\", '') | split(', ') }}"
195195
template:
196196
src: "{{ kdevops_hosts_template }}"
197-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
197+
dest: "{{ ansible_cfg_inventory }}"
198198
force: yes
199199
trim_blocks: True
200200
lstrip_blocks: True
@@ -224,11 +224,11 @@
224224
- kdevops_workflow_enable_blktests
225225
- ansible_hosts_template.stat.exists
226226

227-
- name: Generate the Ansible hosts file for a dedicated blktests setup
227+
- name: Generate the Ansible inventory file for a dedicated blktests setup
228228
tags: [ 'hosts' ]
229229
template:
230230
src: "{{ kdevops_hosts_template }}"
231-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
231+
dest: "{{ ansible_cfg_inventory }}"
232232
force: yes
233233
trim_blocks: True
234234
lstrip_blocks: True
@@ -250,11 +250,11 @@
250250
- kdevops_workflow_enable_selftests
251251
- ansible_hosts_template.stat.exists
252252

253-
- name: Generate the Ansible hosts file for a dedicated selftests setup
253+
- name: Generate the Ansible inventory file for a dedicated selftests setup
254254
tags: [ 'hosts' ]
255255
template:
256256
src: "{{ kdevops_hosts_template }}"
257-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
257+
dest: "{{ ansible_cfg_inventory }}"
258258
force: yes
259259
trim_blocks: True
260260
lstrip_blocks: True
@@ -291,11 +291,11 @@
291291
- kdevops_workflows_dedicated_workflow
292292
- kdevops_workflow_enable_sysbench
293293

294-
- name: Generate the Ansible hosts file for a dedicated sysbench setup
294+
- name: Generate the Ansible inventory file for a dedicated sysbench setup
295295
tags: [ 'hosts' ]
296296
template:
297297
src: "{{ kdevops_hosts_template }}"
298-
dest: "{{ topdir_path }}/{{ kdevops_hosts }}"
298+
dest: "{{ ansible_cfg_inventory }}"
299299
force: yes
300300
trim_blocks: True
301301
lstrip_blocks: True
@@ -306,7 +306,7 @@
306306

307307
- name: Verify if final host file exists
308308
stat:
309-
path: "{{ topdir_path }}/{{ kdevops_hosts }}"
309+
path: "{{ ansible_cfg_inventory }}"
310310
register: final_hosts_file
311311

312312
- name: Fail if the dedicated workflow has no rules for node configuration for hosts file configuration

0 commit comments

Comments
 (0)