use random password for the agents admin password.

This commit is contained in:
Raphael Yu 2017-11-30 17:12:19 +08:00 коммит произвёл Raphael Yu
Родитель b0c26cede0
Коммит d9490798aa
2 изменённых файлов: 12 добавлений и 11 удалений

Просмотреть файл

@ -295,7 +295,7 @@ sudo service jenkins restart
msi_cred=$(cat <<EOF msi_cred=$(cat <<EOF
<com.microsoft.azure.util.AzureMsiCredentials> <com.microsoft.azure.util.AzureMsiCredentials>
<scope>GLOBAL</scope> <scope>GLOBAL</scope>
<id>sp</id> <id>azure_service_principal</id>
<description>Local MSI</description> <description>Local MSI</description>
<msiPort>50342</msiPort> <msiPort>50342</msiPort>
</com.microsoft.azure.util.AzureMsiCredentials> </com.microsoft.azure.util.AzureMsiCredentials>
@ -304,7 +304,7 @@ EOF
sp_cred=$(cat <<EOF sp_cred=$(cat <<EOF
<com.microsoft.azure.util.AzureCredentials> <com.microsoft.azure.util.AzureCredentials>
<scope>GLOBAL</scope> <scope>GLOBAL</scope>
<id>sp</id> <id>azure_service_principal</id>
<description>Manual Service Principal</description> <description>Manual Service Principal</description>
<data> <data>
<subscriptionId>${subscription_id}</subscriptionId> <subscriptionId>${subscription_id}</subscriptionId>
@ -335,7 +335,7 @@ vm_agent_conf=conf=$(cat <<EOF
<clouds> <clouds>
<com.microsoft.azure.vmagent.AzureVMCloud> <com.microsoft.azure.vmagent.AzureVMCloud>
<name>AzureVMAgents</name> <name>AzureVMAgents</name>
<credentialsId>sp</credentialsId> <credentialsId>azure_service_principal</credentialsId>
<maxVirtualMachinesLimit>10</maxVirtualMachinesLimit> <maxVirtualMachinesLimit>10</maxVirtualMachinesLimit>
<resourceGroupReferenceType>existing</resourceGroupReferenceType> <resourceGroupReferenceType>existing</resourceGroupReferenceType>
<existingResourceGroupName>${resource_group}</existingResourceGroupName> <existingResourceGroupName>${resource_group}</existingResourceGroupName>
@ -353,7 +353,7 @@ vm_agent_conf=conf=$(cat <<EOF
<shutdownOnIdle>false</shutdownOnIdle> <shutdownOnIdle>false</shutdownOnIdle>
<imageTopLevelType>basic</imageTopLevelType> <imageTopLevelType>basic</imageTopLevelType>
<builtInImage>Windows Server 2016</builtInImage> <builtInImage>Windows Server 2016</builtInImage>
<credentialsId>agent</credentialsId> <credentialsId>agent_admin_account</credentialsId>
<retentionTimeInMin>60</retentionTimeInMin> <retentionTimeInMin>60</retentionTimeInMin>
</com.microsoft.azure.vmagent.AzureVMAgentTemplate> </com.microsoft.azure.vmagent.AzureVMAgentTemplate>
<com.microsoft.azure.vmagent.AzureVMAgentTemplate> <com.microsoft.azure.vmagent.AzureVMAgentTemplate>
@ -369,7 +369,7 @@ vm_agent_conf=conf=$(cat <<EOF
<shutdownOnIdle>false</shutdownOnIdle> <shutdownOnIdle>false</shutdownOnIdle>
<imageTopLevelType>basic</imageTopLevelType> <imageTopLevelType>basic</imageTopLevelType>
<builtInImage>Ubuntu 16.04 LTS</builtInImage> <builtInImage>Ubuntu 16.04 LTS</builtInImage>
<credentialsId>agent</credentialsId> <credentialsId>agent_admin_account</credentialsId>
<retentionTimeInMin>60</retentionTimeInMin> <retentionTimeInMin>60</retentionTimeInMin>
</com.microsoft.azure.vmagent.AzureVMAgentTemplate> </com.microsoft.azure.vmagent.AzureVMAgentTemplate>
</vmTemplates> </vmTemplates>
@ -384,7 +384,7 @@ aci_agent_conf=$(cat <<EOF
<clouds> <clouds>
<com.microsoft.jenkins.containeragents.aci.AciCloud> <com.microsoft.jenkins.containeragents.aci.AciCloud>
<name>AciAgents</name> <name>AciAgents</name>
<credentialsId>sp</credentialsId> <credentialsId>azure_service_principal</credentialsId>
<resourceGroup>${resource_group}</resourceGroup> <resourceGroup>${resource_group}</resourceGroup>
<templates> <templates>
<com.microsoft.jenkins.containeragents.aci.AciContainerTemplate> <com.microsoft.jenkins.containeragents.aci.AciContainerTemplate>
@ -404,13 +404,14 @@ aci_agent_conf=$(cat <<EOF
EOF EOF
) )
agent_admin_password=$(head /dev/urandom | tr -dc A-Z | head -c 4)$(head /dev/urandom | tr -dc a-z | head -c 4)$(head /dev/urandom | tr -dc 0-9 | head -c 4)'!@'
agent_admin_cred=$(cat <<EOF agent_admin_cred=$(cat <<EOF
<com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl> <com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
<scope>GLOBAL</scope> <scope>GLOBAL</scope>
<id>agent</id> <id>agent_admin_account</id>
<description>the admin account for the vm agents</description> <description>the admin account for the vm agents</description>
<username>agentadmin</username> <username>agentadmin</username>
<password>1234QWERasdf#</password> <password>${agent_admin_password}</password>
</com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl> </com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
EOF EOF
) )

Просмотреть файл

@ -193,7 +193,7 @@
"visible": true "visible": true
}, },
{ {
"name": "section1", "name": "spSection",
"type": "Microsoft.Common.Section", "type": "Microsoft.Common.Section",
"label": "Service Principal", "label": "Service Principal",
"elements": [ "elements": [
@ -263,8 +263,8 @@
"location": "[location()]", "location": "[location()]",
"jenkinsReleaseType": "[steps('firstStep').jenkinsReleaseType]", "jenkinsReleaseType": "[steps('firstStep').jenkinsReleaseType]",
"spType": "[steps('secondStep').sptype]", "spType": "[steps('secondStep').sptype]",
"spId": "[steps('secondStep').section1.spid]", "spId": "[steps('secondStep').spSection.spid]",
"spSecret": "[steps('secondStep').section1.spsecret]", "spSecret": "[steps('secondStep').spSection.spsecret]",
"enableCloudAgents": "[steps('secondStep').enableCloudAgents]" "enableCloudAgents": "[steps('secondStep').enableCloudAgents]"
} }
} }