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

Support ansible provision mode for remote playbook #2283

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

afbjorklund
Copy link
Contributor

@afbjorklund afbjorklund commented Apr 15, 2024

Closes #2282

Needs docs.


lima.yaml (based on debian.yaml)

...

provision:
- mode: ansible
  playbook: playbook.yaml

inventory.yaml (auto-generated)

lima:
  hosts:
    ansible:
      ansible_connection: ssh
      ansible_host: lima-ansible
      ansible_ssh_common_args: -F /home/anders/.lima/ansible/ssh.config

playbook.yaml

- name: My first play
  hosts: all
  tasks:
   - name: Ping my hosts
     ansible.builtin.ping:

   - name: Print message
     ansible.builtin.debug:
      msg: Hello world

https://docs.ansible.com/ansible/latest/getting_started/get_started_playbook.html

INFO[0021] [hostagent] The final requirement 1 of 1 is satisfied 
INFO[0022] Waiting for ansible playbook "playbook.yaml" 
 ______________________
< PLAY [My first play] >
 ----------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 ________________________
< TASK [Gathering Facts] >
 ------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

[WARNING]: Platform linux on host ansible is using the discovered Python
interpreter at /usr/bin/python3, but future installation of another Python
interpreter could change this. See https://docs.ansible.com/ansible/2.9/referen
ce_appendices/interpreter_discovery.html for more information.
ok: [ansible]
 ______________________
< TASK [Ping my hosts] >
 ----------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [ansible]
 ______________________
< TASK [Print message] >
 ----------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [ansible] => {
    "changed": false,
    "msg": "Hello world"
}
 ____________
< PLAY RECAP >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ansible                    : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

INFO[0024] READY. Run `limactl shell ansible` to open the shell. 

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
@afbjorklund afbjorklund marked this pull request as ready for review May 7, 2024 10:17
@AkihiroSuda AkihiroSuda added this to the v0.22.1 (tentative) milestone May 7, 2024
@@ -291,6 +291,10 @@ func watchHostAgentEvents(ctx context.Context, inst *store.Instance, haStdoutPat
return true
}

if xerr := runAnsibleProvision(ctx, inst); xerr != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Copy link
Member

@balajiv113 balajiv113 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

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

Successfully merging this pull request may close these issues.

Additional provisioning formats beyond shell scripts
3 participants