diff mbox series

[v2,05/12] update_ssh_config: Add tags to steps

Message ID 20250205155252.1317763-6-cel@kernel.org (mailing list archive)
State New
Headers show
Series Replace terraform update_ssh_config module | expand

Commit Message

Chuck Lever Feb. 5, 2025, 3:52 p.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

I'm about to add new functions to the update_ssh_config role that
can be run by specifying tags on the ansible-playbook command line.

To run only the steps that update the controller's .ssh/config
Include directive, add a "deps" tag.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 playbooks/roles/update_ssh_config/tasks/main.yml | 8 ++++++++
 scripts/ssh.Makefile                             | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/playbooks/roles/update_ssh_config/tasks/main.yml b/playbooks/roles/update_ssh_config/tasks/main.yml
index 6a7b58d8a556..417781936f7f 100644
--- a/playbooks/roles/update_ssh_config/tasks/main.yml
+++ b/playbooks/roles/update_ssh_config/tasks/main.yml
@@ -1,10 +1,12 @@ 
 ---
 - name: Check that the controller's ssh config file exists
+  tags: deps
   ansible.builtin.stat:
     path: "{{ sshconfig }}"
   register: ssh_config
 
 - name: Check that the kdevops Include directive is present
+  tags: deps
   ansible.builtin.lineinfile:
     path: "{{ sshconfig }}"
     regexp: "Include ~/.ssh/config_kdevops_*"
@@ -15,6 +17,7 @@ 
   when: ssh_config.stat.exists
 
 - name: Check that the Include directive has a kdevops_version comment
+  tags: deps
   ansible.builtin.lineinfile:
     path: "{{ sshconfig }}"
     regexp: "^#(.*)kdevops_version(.*)"
@@ -27,6 +30,7 @@ 
 # If both the include directive was found and kdevops version comment was found
 # we bail right away to avoid updating the ssh config file always.
 - name: Check if the new fixed include directive was used
+  tags: deps
   ansible.builtin.meta: end_play
   when:
     - ssh_config.stat.exists
@@ -34,6 +38,7 @@ 
     - fixed_ssh_entry.found
 
 - name: Remove the stale Include directive
+  tags: deps
   ansible.builtin.lineinfile:
     path: "{{ sshconfig }}"
     line: "Include ~/.ssh/config_kdevops_*"
@@ -41,6 +46,7 @@ 
   when: ssh_config.stat.exists
 
 - name: Remove stale kdevops comments
+  tags: deps
   ansible.builtin.lineinfile:
     path: "{{ sshconfig }}"
     regexp: "^#(.*)kdevops(.*)"
@@ -48,6 +54,7 @@ 
   when: ssh_config.stat.exists
 
 - name: Remove extraneous extra new lines
+  tags: deps
   ansible.builtin.replace:
     path: "{{ sshconfig }}"
     regexp: '(^\s*$)'
@@ -56,6 +63,7 @@ 
 
 # ssh include directives must follow a new line.
 - name: Add a proper Include directive to {{ sshconfig }}
+  tags: deps
   ansible.builtin.blockinfile:
     path: "{{ sshconfig }}"
     insertbefore: BOF
diff --git a/scripts/ssh.Makefile b/scripts/ssh.Makefile
index cf79a1dd6c27..caa4bc797c48 100644
--- a/scripts/ssh.Makefile
+++ b/scripts/ssh.Makefile
@@ -25,7 +25,7 @@  $(KDEVOPS_SSH_PRIVKEY): .config
 PHONY += update-ssh-config
 update-ssh-config:
 	$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
-		--inventory localhost, \
+		--inventory localhost, --tags deps \
 		playbooks/update_ssh_config.yml \
 		--extra-vars=@./extra_vars.yaml \
 		-e 'ansible_python_interpreter=/usr/bin/python3'