我正在尝试通过 ansible 2.9.9 安装 jenkins-x 版本 2.0.785。
如何处理安装 JX 时收到的提示,例如“请输入您希望与 git 一起使用的名称:”?当我执行 JX 安装命令时,我会收到多个需要处理的提示。
即使“--git-username=automation”已在 JX 安装命令中传递,我也会收到上述提示。我在ansible中尝试了expect和shell模块。
请给我一个解决方案,我可以通过 ansible 处理这些提示。
试过: -
- name: Handling multiple prompts
expect:
command: jx install --git-provider-kind bitbucketserver --git-provider-url http://rtx-swtl-git.fnc.net.local --git-username automation --default-environment-prefix TestProject --git-api-token MzI1ODg1NjA1NTk4OqjiP9N3lr4iHt9L5rofdaWMqsgW --on-premise --external-ip {{ hostvars[groups["kubemaster"][0]]["ip"] }} --verbose --static-jenkins=true --provider=openshift
responses:
Question:
- Please enter the name you wish to use with git: automation
timeout: 60
- name: Handling multiple prompts
expect:
command: jx install --git-provider-kind bitbucketserver --git-provider-url http://rtx-swtl-git.fnc.net.local --git-username automation --default-environment-prefix TestProject --git-api-token MzI1ODg1NjA1NTk4OqjiP9N3lr4iHt9L5rofdaWMqsgW --on-premise --external-ip {{ hostvars[groups["kubemaster"][0]]["ip"] }} --verbose --static-jenkins=true --provider=openshift
responses:
Please enter the name you wish to use with git: "automation"
- name: Handling multiple prompts
become: yes
shell: |
automation '' | jx install --git-provider-kind bitbucketserver --git-provider-url http://rtx-swtl-git.fnc.net.local --git-username automation --default-environment-prefix Testproject --git-api-token MzI1ODg1NjA1NTk4OqjiP9N3lr4iHt9L5rofdaWMqsgW --on-premise --external-ip {{ hostvars[groups["kubemaster"][0]]["ip"] }} --verbose --static-jenkins true --provider openshift
这些不会在 ansible 日志的 stderr 部分给出任何错误,唯一的事情是我收到了下面附加的 RED 日志,并且它没有进一步执行安装步骤。
输出:-
fatal: [master]: FAILED! => {
"changed": true,
"cmd": "jx install --git-provider-kind bitbucketserver --git-provider-url http://rtx-swtl-git.fnc.net.local --git-username automation --default-environment-prefix TestProject --git-api-token MzI1ODg1NjA1NTk4OqjiP9N3lr4iHt9L5rofdaWMqsgW --on-premise --external-ip 167.254.204.90 --verbose --static-jenkins=true --provider=openshift --domain=jenkinsx.io",
"delta": "0:03:00.190343",
"end": "2020-06-17 06:44:03.620694",
"invocation": {
"module_args": {
"chdir": null,
"command": "jx install --git-provider-kind bitbucketserver --git-provider-url http://rtx-swtl-git.fnc.net.local --git-username automation --default-environment-prefix TestProject --git-api-token MzI1ODg1NjA1NTk4OqjiP9N3lr4iHt9L5rofdaWMqsgW --on-premise --external-ip 167.254.204.90 --verbose --static-jenkins=true --provider=openshift --domain=jenkinsx.io",
"creates": null,
"echo": false,
"removes": null,
"responses": {
"Question": [
{
"Please enter the name you wish to use with git": "automation"
},
{
"Please enter the email address you wish to use with git": "automation@fujitsu.com"
},
{
"\\? Do you wish to use automation as the local Git user for http://rtx-swtl-git.fnc.net.local server": "y"
},
{
"\\? Do you wish to use http://rtx-swtl-git.fnc.net.local as the pipelines Git server": "y"
}
]
},
"timeout": 180
}
},
"msg": "command exceeded timeout",
"rc": null,
"start": "2020-06-17 06:41:03.430351",
"stdout": "\u001b[1m\u001b[32m?\u001b[0m\u001b[0m \u001b[1mConfigured Jenkins installation type\u001b[0m: \u001b[36mStatic Jenkins Server and Jenkinsfiles\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: checking installation flags\r\n\u001b[36mDEBUG\u001b[0m: flags after checking - &{ConfigFile: InstallOnly:false Domain: ExposeControllerURLTemplate: ExposeControllerPathMode: AzureRegistrySubscription: DockerRegistry:docker-registry.default.svc:5000 DockerRegistryOrg: Provider:openshift VersionsRepository:https://github.com/jenkins-x/jenkins-x-versions.git VersionsGitRef: Version: LocalHelmRepoName:releases Namespace:jx CloudEnvRepository:https://github.com/jenkins-x/cloud-environments NoDefaultEnvironments:false RemoteEnvironments:false DefaultEnvironmentPrefix:TestProject LocalCloudEnvironment:false EnvironmentGitOwner: Timeout:6000 HelmTLS:false RegisterLocalHelmRepo:false CleanupTempFiles:true Prow:false DisableSetKubeContext:false Dir: Vault:false RecreateVaultBucket:true Tekton:false KnativeBuild:false BuildPackName: Kaniko:false GitOpsMode:false NoGitOpsEnvApply:false NoGitOpsEnvRepo:false NoGitOpsEnvSetup:false NoGitOpsVault:false NextGeneration:false StaticJenkins:true LongTermStorage:false LongTermStorageBucketName: CloudBeesDomain: CloudBeesAuth:}\r\n\u001b[36mDEBUG\u001b[0m: Setting the dev namespace to: \u001b[32mjx\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: Using helmBinary \u001b[32mhelm\u001b[0m with feature flag: \u001b[32mnone\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: \u001b[32mhelm\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/helm\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: \u001b[32mkubectl\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/kubectl\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: \u001b[32mhelm\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/helm\u001b[0m\r\nContext \"jx/master-167-254-204-90-nip-io:8443/waruser\" modified.\r\n\u001b[36mDEBUG\u001b[0m: \u001b[32mkubectl\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/kubectl\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: \u001b[32mhelm\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/helm\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: Storing the kubernetes provider openshift in the TeamSettings\r\n\u001b[36mDEBUG\u001b[0m: Enabling helm template mode in the TeamSettings\r\nGit configured for user: \u001b[32mautomation\u001b[0m and email \u001b[32mautomation@fujitsu.com\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: Using \u001b[32mhelm2\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: Skipping \u001b[32mtiller\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: Using helmBinary \u001b[32mhelm\u001b[0m with feature flag: \u001b[32mtemplate-mode\u001b[0m\r\n\u001b[36mDEBUG\u001b[0m: Initialising Helm '\u001b[32minit --client-only\u001b[0m'\r\nhelm installed and configured\r\nNot installing ingress as using OpenShift which uses Route and its own mechanism of ingress\r\nEnabling anyuid for the Jenkins service account in namespace jx\r\nscc \"anyuid\" added to: [\"system:serviceaccount:jx:jenkins\"]\r\nscc \"hostaccess\" added to: [\"system:serviceaccount:jx:jenkins\"]\r\nscc \"privileged\" added to: [\"system:serviceaccount:jx:jenkins\"]\r\nscc \"anyuid\" added to: [\"system:serviceaccount:jx:default\"]\r\n\u001b[36mDEBUG\u001b[0m: Long Term Storage not supported by provider 'openshift', disabling this option\r\nSet up a Git username and API token to be able to perform CI/CD\r\n\u001b[36mDEBUG\u001b[0m: merging pipeline secrets with local secrets\r\n\u001b[0G\u001b[2K\u001b[1;92m? \u001b[0m\u001b[1;99mDo you wish to use automation as the local Git user for http://rtx-swtl-git.fnc.net.local server: \u001b[0m\u001b[37m(Y/n) \u001b[0m\u001b[?25l\u001b7\u001b[999;999f\u001b[6n",
"stdout_lines": [
"\u001b[1m\u001b[32m?\u001b[0m\u001b[0m \u001b[1mConfigured Jenkins installation type\u001b[0m: \u001b[36mStatic Jenkins Server and Jenkinsfiles\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: checking installation flags",
"\u001b[36mDEBUG\u001b[0m: flags after checking - &{ConfigFile: InstallOnly:false Domain: ExposeControllerURLTemplate: ExposeControllerPathMode: AzureRegistrySubscription: DockerRegistry:docker-registry.default.svc:5000 DockerRegistryOrg: Provider:openshift VersionsRepository:https://github.com/jenkins-x/jenkins-x-versions.git VersionsGitRef: Version: LocalHelmRepoName:releases Namespace:jx CloudEnvRepository:https://github.com/jenkins-x/cloud-environments NoDefaultEnvironments:false RemoteEnvironments:false DefaultEnvironmentPrefix:TestProject LocalCloudEnvironment:false EnvironmentGitOwner: Timeout:6000 HelmTLS:false RegisterLocalHelmRepo:false CleanupTempFiles:true Prow:false DisableSetKubeContext:false Dir: Vault:false RecreateVaultBucket:true Tekton:false KnativeBuild:false BuildPackName: Kaniko:false GitOpsMode:false NoGitOpsEnvApply:false NoGitOpsEnvRepo:false NoGitOpsEnvSetup:false NoGitOpsVault:false NextGeneration:false StaticJenkins:true LongTermStorage:false LongTermStorageBucketName: CloudBeesDomain: CloudBeesAuth:}",
"\u001b[36mDEBUG\u001b[0m: Setting the dev namespace to: \u001b[32mjx\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: Using helmBinary \u001b[32mhelm\u001b[0m with feature flag: \u001b[32mnone\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: \u001b[32mhelm\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/helm\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: \u001b[32mkubectl\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/kubectl\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: \u001b[32mhelm\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/helm\u001b[0m",
"Context \"jx/master-167-254-204-90-nip-io:8443/waruser\" modified.",
"\u001b[36mDEBUG\u001b[0m: \u001b[32mkubectl\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/kubectl\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: \u001b[32mhelm\u001b[0m is already available on your PATH at \u001b[32m/usr/bin/helm\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: Storing the kubernetes provider openshift in the TeamSettings",
"\u001b[36mDEBUG\u001b[0m: Enabling helm template mode in the TeamSettings",
"Git configured for user: \u001b[32mautomation\u001b[0m and email \u001b[32mautomation@fujitsu.com\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: Using \u001b[32mhelm2\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: Skipping \u001b[32mtiller\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: Using helmBinary \u001b[32mhelm\u001b[0m with feature flag: \u001b[32mtemplate-mode\u001b[0m",
"\u001b[36mDEBUG\u001b[0m: Initialising Helm '\u001b[32minit --client-only\u001b[0m'",
"helm installed and configured",
"Not installing ingress as using OpenShift which uses Route and its own mechanism of ingress",
"Enabling anyuid for the Jenkins service account in namespace jx",
"scc \"anyuid\" added to: [\"system:serviceaccount:jx:jenkins\"]",
"scc \"hostaccess\" added to: [\"system:serviceaccount:jx:jenkins\"]",
"scc \"privileged\" added to: [\"system:serviceaccount:jx:jenkins\"]",
"scc \"anyuid\" added to: [\"system:serviceaccount:jx:default\"]",
"\u001b[36mDEBUG\u001b[0m: Long Term Storage not supported by provider 'openshift', disabling this option",
"Set up a Git username and API token to be able to perform CI/CD",
"\u001b[36mDEBUG\u001b[0m: merging pipeline secrets with local secrets",
"\u001b[0G\u001b[2K\u001b[1;92m? \u001b[0m\u001b[1;99mDo you wish to use automation as the local Git user for http://rtx-swtl-git.fnc.net.local server: \u001b[0m\u001b[37m(Y/n) \u001b[0m\u001b[?25l\u001b7\u001b[999;999f\u001b[6n"
]
}
PLAY RECAP *************************************************************************************************************************************************************
master : ok=3 changed=1 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0