有多种方式可配置云模板,以支持对 vCenter 计算资源进行基于 Puppet 的配置管理。

vSphere 上的 Puppet,具有用户名和密码身份验证

以下示例显示了 vSphere OVA 上 Puppet 的示例 YAML 代码,该 Puppet 具有用户名和密码身份验证。

表 1.
示例... 示例蓝图 YAML
vSphere OVA 上 Puppet 的 YAML 代码,该 Puppet 具有用户名和密码身份验证。
inputs:
  username:
    type: string
    title: Username
    default: puppet
  password:
    type: string
    title: Password
    encrypted: true
    default: VMware@123
resources:
  Puppet_Agent:
    type: Cloud.Puppet
    properties:
      provider: PEonAWS
      environment: dev
      role: 'role::linux_webserver'
      username: '${input.username}'
      password: '${input.password}'
      useSudo: true
      host: '${Webserver.*}’
      osType: linux
      agentConfiguration:
        runInterval: 15m
        certName: ‘${Machine.address}'
  Webserver:
    type: Cloud.vSphere.Machine
    properties:
      cpuCount: 1
      totalMemoryMB: 1024
      imageRef: >-
https://cloud-images.ubuntu.com/releases/16.04/release-20170307/ubuntu-16.04-server-cloudimg-amd64.ova
      cloudConfig: |
        #cloud-config
        ssh_pwauth: yes
        chpasswd:
          list: |
            ${input.username}:${input.password}
          expire: false
        users:
          - default
          - name: ${input.username}
            lock_passwd: false
            sudo: ['ALL=(ALL) NOPASSWD:ALL']
            groups: [wheel, sudo, admin]
            shell: '/bin/bash'
            ssh-authorized-keys:
              - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDytVL+Q6+vGbmkXoRpX dmettem@dmettem-m01.vmware.com
        runcmd:
          - echo "Defaults:${input.username}
vSphere OVA 上 Puppet 的 YAML 代码,该 Puppet 对计算资源进行用户名和密码身份验证。
inputs:
  username:
    type: string
    title: Username
    default: puppet
  password:
    type: string
    title: Password
    encrypted: true
    default: VMware@123
resources:
  Puppet_Agent:
    type: Cloud.Puppet
    properties:
      provider: PEonAWS
      environment: dev
      role: 'role::linux_webserver'
      username: '${input.username}'
      password: '${input.password}'
      useSudo: true
      host: '${Webserver.*}’
      osType: linux
      agentConfiguration:
        runInterval: 15m
        certName: ‘${Machine.address}'
  Webserver:
    type: Cloud.vSphere.Machine
    properties:
      cpuCount: 1
      totalMemoryMB: 1024
      imageRef: >-
https://cloud-images.ubuntu.com/releases/16.04/release-20170307/ubuntu-16.04-server-cloudimg-amd64.ova
      cloudConfig: |
        #cloud-config
        ssh_pwauth: yes
        chpasswd:
          list: |
            ${input.username}:${input.password}
          expire: false
        users:
          - default
          - name: ${input.username}
            lock_passwd: false
            sudo: ['ALL=(ALL) NOPASSWD:ALL']
            groups: [wheel, sudo, admin]
            shell: '/bin/bash'
            ssh-authorized-keys:
              - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDytVL+Q6+vGbmkXoRpX dmettem@dmettem-m01.vmware.com
        runcmd:
          - echo "Defaults:${input.username}
vCenter 上 Puppet 的 YAML 代码,该 Puppet 对计算资源启用了远程访问密码身份验证。
inputs:
  username:
    type: string
    title: Username
    description: Username to use to install Puppet agent
    default: puppet
  password:
    type: string
    title: Password
    default: VMware@123
    encrypted: true
    description: Password for the given username to install Puppet agent
resources:
  Puppet-Ubuntu:
    type: Cloud.vSphere.Machine
    properties:
      flavor: small
      imageRef: >-
        https://cloud-images.ubuntu.com/releases/16.04/release-20170307/ubuntu-16.04-server-cloudimg-amd64.ova
      remoteAccess:
        authentication: usernamePassword
        username: '${input.username}'
        password: '${input.password}'
  Puppet_Agent:
    type: Cloud.Puppet
    properties:
      provider: PEMasterOnPrem
      environment: production
      role: 'role::linux_webserver'
      username: '${input.username}'
      password: '${input.password}'
      host: '${Puppet-Ubuntu.*}'
      useSudo: true
      agentConfiguration:
        certName: '${Puppet-Ubuntu.address}'

vSphere 上的 Puppet,具有生成的 PublicPrivateKey 身份验证

表 2.
示例... 示例蓝图 YAML
vSphere OVA 上 Puppet 的 YAML 代码,具有针对计算资源的生成的 PublicPrivateKey 身份验证。
inputs: {}
resources:
  Machine:
    type: Cloud.vSphere.Machine
    properties:
      flavor: small
      imageRef: >-
https://cloud-images.ubuntu.com/releases/16.04/release-20170307/ubuntu-16.04-server-cloudimg-amd64.ova
      remoteAccess:
        authentication: generatedPublicPrivateKey
  Puppet_Agent:
    type: Cloud.Puppet
    properties:
      provider: puppet-BlueprintProvisioningITSuite
      environment: production
      role: 'role::linux_webserver'
      host: '${Machine.*}’
      osType: linux
      username: ubuntu
      useSudo: true
      agentConfiguration:
        runInterval: 15m
        certName: ‘${Machine.address}'
          - echo "Defaults:${input.username}