Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: is there a way to pass a key from the Key Store to an ansible playbook to be used in a dynamically created hosts group? #2541

Open
oussjarrousse opened this issue Nov 14, 2024 · 1 comment
Labels

Comments

@oussjarrousse
Copy link
Contributor

Question

In my playbook I have two stages:
1- the first part creates a new VPS on a cloud provider. (The VPS is created with an ssh key that has an ID in that cloud provider.)
2- the second configures that VPS.

....
....
    - name: Add the new vps to inventory
      ansible.builtin.add_host:
        name: "{{ vps_ip }}"
        groups: new_vps
        ansible_host: "{{ vps_ip }}"
        ansible_user: root
        ansible_ssh_host_key_checking: false
        
- name: Configure the new VPS
  hosts: new_vps
  gather_facts: yes
  tasks:
    - name: Debug
       debug:
         msg: configuring the newly created VPS
...
...

Ansible tries to connect the the VPS in the second stage but fails because it needs the ssh key.

The ssh key is defined in the Key Store in Semaphore.

Is there a way to pass that ssh key to ansible so that it can be used in the second stage?

Related to

Ansible (task execution)

@oussjarrousse
Copy link
Contributor Author

potentially a duplicate of #2302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant