-
Notifications
You must be signed in to change notification settings - Fork 5
added env variables for ssh password and passphrase #6
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| RUNNER_TAG_LIST=<your value> | ||
| REGISTRATION_TOKEN=<your value> | ||
| RUNNER_NAME=<your value> | ||
| CI_SERVER_URL=<your value> | ||
| RUNNER_BUILDS_DIR=<your value> | ||
| RUNNER_CACHE_DIR=<your value> | ||
| CONCURRENT=<your value> | ||
|
|
||
| FLAVOR=<your value> | ||
| BUILDER_IMAGE=<your value> | ||
| NETWORK=<your value> | ||
| KEY_PAIR_NAME=<your value> | ||
| SECURITY_GROUP=<your value> | ||
| USERNAME=<your value> | ||
| PASSWORD=<your value> | ||
| PASSPHRASE=<your value> | ||
|
|
||
| OS_AUTH_URL=<your value> | ||
| OS_PROJECT_NAME=<your value> | ||
| OS_USERNAME=<your value> | ||
| OS_PASSWORD=<your value> | ||
| OS_PROJECT_DOMAIN_NAME=<your value> | ||
| OS_USER_DOMAIN_NAME=<your value> | ||
| OS_REGION_NAME=<your value> | ||
| OS_IDENTITY_API_VERSION=<your value> | ||
| OS_INTERFACE=<your value> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,14 +39,25 @@ def check_ssh(ip: str) -> None: | |
|
|
||
| @retry(reraise=True, stop=stop_after_attempt(3), wait=wait_fixed(10)) | ||
| def connect(): | ||
| ssh_client.connect( | ||
| hostname=ip, | ||
| username=env.USERNAME, | ||
| pkey=pkey, | ||
| look_for_keys=False, | ||
| allow_agent=False, | ||
| timeout=20, | ||
| ) | ||
| if len(env.PASSWORD) > 1: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should take into account the case when
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant def get_cred():
if env.PASSWORD:
return {"password": env.PASSWORD}
if env.PRIVATE_KEY:
pkey = paramiko.rsakey.RSASHA256Key.from_private_key_file(env.PRIVATE_KEY_PATH)
return {"passphrase": env.PASSPHRASE, "pkey": pkey}
raise ValueError("Either PASSWORD or PRIVATE_KEY must be defined")
...
ssh_client.connect(
hostname=ip,
username=env.USERNAME,
look_for_keys=False,
allow_agent=False,
timeout=60,
**get_cred()
)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, you can of course write it like that. How about you merge it and change this style detail then? |
||
| ssh_client.connect( | ||
| hostname=ip, | ||
| username=env.USERNAME, | ||
| password=env.PASSWORD, | ||
| look_for_keys=False, | ||
| allow_agent=False, | ||
| timeout=60, | ||
| ) | ||
| else: | ||
| ssh_client.connect( | ||
| hostname=ip, | ||
| username=env.USERNAME, | ||
| pkey=pkey, | ||
| passphrase=env.PASSPHRASE, | ||
| look_for_keys=False, | ||
| allow_agent=False, | ||
| timeout=60, | ||
| ) | ||
|
|
||
| connect() | ||
| ssh_client.close() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be not mandatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty should work - I however did not explicitly test it without