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

SSH connect issues #253

Open
fernflower opened this issue Dec 16, 2024 · 1 comment
Open

SSH connect issues #253

fernflower opened this issue Dec 16, 2024 · 1 comment

Comments

@fernflower
Copy link

fernflower commented Dec 16, 2024

With v0.2.6 of the plugin and the following template

{
    "variables":
        {
            "apikey": "MY_SECRET_API_KEY",
            "access_key": "MY_SECRET_ACCESS_KEY",
            "secret_key": "MY_SECRET_SECRET_KEY",
            "playbook_file": "",
            "extra_arguments": ""
        },
    "builders":[
        {
            "type": "powervs",
            "account_id": "4207b73c20f249499b08ed2136bb1819",
            "service_instance_id": "3f595cdc-b316-48a6-b6df-d8ac004c6078",
            "api_key": "{{ user `apikey` }}",
            "debug": true,
            "zone": "us-east",
            "source": {
                "name": "rhel-9-6-0-20241209-d-1"
            },
            "instance_name": "packer-build-{{timestamp}}",
            "key_pair_name": "ivasilev",
            "ssh_username": "cloud-user",
            "ssh_timeout": "3m",
            "capture": {
                "name": "target-image-1",
                "cos": {
                    "bucket": "tft-image-import",
                    "region": "us-east",
                    "access_key": "{{user `access_key`}}",
                    "secret_key": "{{user `secret_key`}}"
                }
            }
        }
    ],
    "provisioners":[
        {
            "type": "ansible",
            "playbook_file": "{{user `playbook_file`}}",
            "extra_arguments": [ "-vv", "--extra-vars", "{{user `ansible_extra_vars`}}" ],
            "ansible_env_vars": [ "ANSIBLE_LOAD_CALLBACK_PLUGINS=1", "ANSIBLE_STDOUT_CALLBACK=debug" ],
            "use_proxy": false
        }
    ]
}

I am unfortunately hitting an issue with packit never establishing ssh connection.

The image I'm using requires either login as cloud-user or passing userdata that would allow root ssh auth. Unfortunately specifying ssh_username: cloud-user in the template does not cut it and there looks like no option for supplying userdata to be passed to instance create command (based on what https://github.com/ppc64le-cloud/packer-plugin-powervs/blob/main/builder/powervs/builder.hcl2spec.go#L25 has to offer).

ivasilev@ivasilev-thinkpadp1gen4i:~/projects/ansible-baseos-ci/cli$ packer build -var playbook_file=../images/playbooks/compose/build.yaml ../images/packer/ibmcloud-power-ansible.json 
powervs: output will be in this color.

==> powervs: Importing the Base Image
    powervs: Image found with ID: fe2bd832-1dc3-4fb1-81bd-8fd821745392
==> powervs: Creating network
    powervs: Network Created, Name: public-192_168_5_240-28-VLAN_2063, ID: b3c8b060-fc98-4d97-81d5-fa063283cfce
==> powervs: Creating Instance
    powervs: Creating Instance
    powervs: Instance Created, Name: packer-build-1734382636, ID: 29a6d2f3-657f-4553-b1d3-d5eb25387ffd
    powervs: Fetching IP for machine
    powervs: Machine IP is not yet found, Trying again
    powervs: Machine IP is not yet found, Trying again
==> powervs: Using SSH communicator to connect: 52.116.109.254
==> powervs: Waiting for SSH to become available...
    powervs: Fetching IP for machine
    powervs: Fetching IP for machine
    powervs: Fetching IP for machine
    powervs: Fetching IP for machine
    powervs: Fetching IP for machine
    powervs: Fetching IP for machine
    powervs: Fetching IP for machine
    powervs: Fetching IP for machine
    powervs: Fetching IP for machine
==> powervs: Timeout waiting for SSH.
==> powervs: Deleting the Instance
    powervs: VM still exists, state: ACTIVE
    powervs: VM still exists, state: ACTIVE
    powervs: instance deleted successfully
==> powervs: Deleting the Network
    powervs: Successfully deleted network
Build 'powervs' errored after 6 minutes 8 seconds: Timeout waiting for SSH.

==> Wait completed after 6 minutes 8 seconds

==> Some builds didn't complete successfully and had errors:
--> powervs: Timeout waiting for SSH.

==> Builds finished but no artifacts were created.

At the same time one can totally reach the machine as [email protected] and there is indeed the proper ssh key in ~/.ssh/authorized_keys (the one specified by key_pair_name).

The goal is to achieve the same functionality as the ibmcloud pi plugin instance create call:
ibmcloud pi instance create artemis-pi-manual-boot --image rhel-9-6-0-20241209-d-1 --subnets 969ef856-27e9-4255-ae9e-61b1a7bb6e2f --key-name ivasilev --user-data ~/projects/artemis/server/configuration/userdata_allow_root

@fernflower
Copy link
Author

fernflower commented Dec 17, 2024

Having slept on it and retried in the morning - looks like ssh_private_key_file needs to be marked as required, after I added "ssh_private_key_file": "/home/ivasilev/.ssh/id_rsa" that was maching the keypair one I got to running the playbook.
So not really an issue, maximum something worth documenting (and possibly changing Fetching IP for machine massage to something that actually refers to problems during ssh connection).
Feel free to close, thanks!

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

No branches or pull requests

1 participant