phoenixnap.bmc.server (1.17.0) — module

Manage phoenixNAP Bare Metal Cloud servers

| "added in version" 0.5.0 of phoenixnap.bmc"

Authors: Pavle Jojkic (@pajuga) <pavlej@phoenixnap.com>, Goran Jelenic (@goranje) <goranje@phoenixnap.com>

preview | supported by certified

Install collection

Install with ansible-galaxy collection install phoenixnap.bmc:==1.17.0


Add to requirements.yml

  collections:
    - name: phoenixnap.bmc
      version: 1.17.0

Description

Manage phoenixNAP Bare Metal Cloud servers

This module has a dependency on requests

API is documented at U(https://developers.phoenixnap.com/docs/bmc/1/overview).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# All the examples assume that you have file config.yaml with your 'clientId' and 'clientSecret'
# in location: ~/.pnap/config.yaml
# and generated SSH key pair in location: ~/.ssh/

- name: Create new server for account
  hosts: localhost
  gather_facts: false
  vars_files:
    - ~/.pnap/config.yaml
  tasks:
    - name: Create server
      phoenixnap.bmc.server:
        client_id: "{{ clientId }}"
        client_secret: "{{ clientSecret }}"
        hostnames: [my-server-red, my-server-blue]
        location: PHX
        os: ubuntu/bionic
        type: s1.c1.medium
        state: present
        ssh_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
      register: output
    - name: Print the servers information
      ansible.builtin.debug:
        var: output.servers
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new server | private network example
  hosts: localhost
  gather_facts: false
  vars_files:
    - ~/.pnap/config.yaml
  tasks:
    - name: Create server | private network example
      phoenixnap.bmc.server:
        client_id: "{{ clientId }}"
        client_secret: "{{ clientSecret }}"
        hostnames: server-red
        description: custom description
        location: PHX
        os: ubuntu/bionic
        type: s0.d1.medium
        private_network_configuration_type: USER_DEFINED
        private_networks:
          - id: 60f81608e2f4665962b214db
            ips: [10.0.0.13 - 10.0.0.17]
            dhcp: false
          - id: 60f93142c5c1d6082d31382a
            ips: [10.0.0.11, 10.0.0.12]
            dhcp: false
        state: present
      register: output
    - name: Print the servers information
      ansible.builtin.debug:
        var: output.servers
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Power on servers
  hosts: localhost
  gather_facts: false
  vars_files:
    - ~/.pnap/config.yaml
  tasks:
    - name: Power on servers
      phoenixnap.bmc.server:
        client_id: "{{ clientId }}"
        client_secret: "{{ clientSecret }}"
        hostnames: [my-server-red, my-server-blue]
        state: powered-on
      register: output
    - name: Print the servers information
      ansible.builtin.debug:
        var: output.servers
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Shutdown servers
  hosts: localhost
  gather_facts: false
  vars_files:
    - ~/.pnap/config.yaml
  tasks:
    - name: Shutdown servers
      phoenixnap.bmc.server:
        client_id: "{{ clientId }}"
        client_secret: "{{ clientSecret }}"
        server_ids:
          - e6afba51-7de8-4080-83ab-0f9155706xxx
          - e6afBa51-7dg8-4380-8sab-0f9155705xxx
        state: shutdown
      register: output
    - name: Print the servers information
      ansible.builtin.debug:
        var: output.servers

Inputs

    
os:
    description: The server's OS used when the server was created. See BMC API for current
      list - U(https://developers.phoenixnap.com/docs/bmc/1/types/Server).
    type: str

tags:
    description: Tags to set to server, if any.
    elements: dict
    suboptions:
      name:
        description: The name of the tag.
        type: str
      value:
        description: The value of the tag assigned to the resource.
        type: str
    type: list

type:
    description: Server type ID. See BMC API for current list - U(https://developers.phoenixnap.com/docs/bmc/1/types/Server).
    type: str

force:
    description:
    - parameter controlling advanced features availability.
    - Currently applicable for networking. It is advised to use with caution since it
      might lead to unhealthy setups.
    type: bool

state:
    choices:
    - absent
    - present
    - powered-on
    - powered-off
    - rebooted
    - reset
    - shutdown
    default: present
    description: Desired state of the server.
    type: str

ssh_key:
    description: A list of SSH Keys that will be installed on the Linux server.
    elements: str
    type: list

ip_block:
    description:
    - Used to specify the previously purchased IP blocks to assign to this server upon
      provisioning.
    - Used alongside the USER_DEFINED configurationType.
    - must contain at most 1 item
    type: str

location:
    description: Server Location ID. See BMC API for current list - U(https://developers.phoenixnap.com/docs/bmc/1/types/Server).
    type: str

client_id:
    description: Client ID (Application Management)
    type: str

hostnames:
    description: Name of server.
    elements: str
    type: list

server_ids:
    description: The unique identifier of the server.
    elements: str
    type: list

description:
    description: Description of server.
    type: str

ssh_key_ids:
    description: A list of SSH Key IDs that will be installed on the server in addition
      to any ssh keys specified in request.
    elements: str
    type: list

network_type:
    default: PUBLIC_AND_PRIVATE
    description: The type of network configuration for this server
    type: str

client_secret:
    description: Client Secret (Application Management)
    type: str

pricing_model:
    default: HOURLY
    description: Server pricing model.
    type: str

reservation_id:
    description: Server reservation ID.
    type: str

gateway_address:
    description:
    - The address of the gateway assigned / to assign to the server.
    - When used as part of request body, IP address has to be part of a private/public
      network or an IP block assigned to this server.
    - Gateway address also has to be assigned on an already deployed resource unless the
      address matches the BMC gateway address in a public network/IP block or the force
      query parameter is true.
    type: str

netris_softgate:
    description: Netris Softgate configuration properties.
    suboptions:
      controller_address:
        description: IP address or hostname through which to reach the Netris Controller.
        type: str
      controller_auth_key:
        description:
        - The authentication key of the Netris Controller to connect to.
        - Required for the softgate agent to be able to interact with the Netris Controller.
        type: str
      controller_version:
        description: The version of the Netris Controller to connect to.
        type: str
    type: dict

public_networks:
    description: The list of public networks this server is member of.
    elements: dict
    suboptions:
      id:
        description: The network identifier.
        type: str
      ips:
        description: IPs to configure/configured on the server. IPs must be within the
          network's range.
        elements: str
        type: list
    type: list

rdp_allowed_ips:
    description: List of IPs allowed for RDP access to Windows OS. Supported in single
      IP, CIDR and range format. When undefined, RDP is disabled.
    elements: str
    type: list

delete_ip_blocks:
    description: Required when the state is absent, it determines whether the IP blocks
      assigned to the server should be deleted or not.
    type: bool

private_networks:
    description: The list of private networks this server is member of.
    elements: dict
    suboptions:
      dhcp:
        description: Determines whether DHCP is enabled for this server. Should be false
          if ips is not an empty list.
        type: bool
      id:
        description: The network identifier.
        type: str
      ips:
        description: IPs to configure/configured on the server. Should be null or empty
          list if DHCP is true.
        elements: str
        type: list
    type: list

install_os_to_ram:
    default: false
    description:
    - If true, OS will be installed to and booted from the server's RAM.
    - On restart RAM OS will be lost and the server will not be reachable unless a custom
      bootable OS has been deployed.
    type: bool

netris_controller:
    description: Netris Controller configuration properties.
    type: dict

cloud_init_user_data:
    default: ''
    description: User data for the cloud-init configuration in base64 encoding. NoCloud
      format is supported.
    type: str

storage_configuration:
    description: Storage configuration.
    suboptions:
      rootPartition:
        description: Root partition configuration.
        suboptions:
          raid:
            default: NO_RAID
            description: Software RAID configuration.
            type: str
          size:
            default: -1
            description: The size of the root partition in GB. -1 to use all available
              space.
            type: int
        type: dict
    type: dict

datastore_configuration:
    description: Esxi data storage configuration.
    suboptions:
      datastore_name:
        description: Datastore name.
        type: str
    type: dict

install_default_sshkeys:
    default: true
    description: Whether or not to install ssh keys marked as default in addition to any
      ssh keys specified in this request.
    type: bool

ip_block_configuration_type:
    description:
    - Determines the approach for configuring IP blocks for the server being provisioned.
    - If PURCHASE_NEW is selected, the smallest supported range, depending on the operating
      system, is allocated to the server.
    - Default value is "PURCHASE_NEW"
    type: str

management_access_allowed_ips:
    description: Define list of IPs allowed to access the Management UI. Supported in
      single IP, CIDR and range format.
    elements: str
    type: list

private_network_gateway_address:
    description:
    - Deprecated in favour of a common gateway address across all networks available under
      gateway_address.
    - The address of the gateway assigned / to assign to the server.
    type: str

private_network_configuration_type:
    default: USE_OR_CREATE_DEFAULT
    description: Determines the approach for configuring IP blocks for the server being
      provisioned.
    type: str

Outputs

servers:
  contains:
    clusterId:
      description: The cluster reference id if any.
      returned: always
      sample: x78sdkjds879sd7cx8
      type: str
    coresPerCpu:
      description: The number of physical cores present on each CPU.
      returned: always
      sample: 28
      type: int
    cpu:
      description: A description of the machine CPU.
      returned: always
      sample: E-2276G
      type: str
    cpuCount:
      description: The number of CPUs available in the system.
      returned: always
      sample: 2
      type: int
    cpuFrequency:
      description: The CPU frequency in GHz.
      returned: always
      sample: 3.6
      type: float
    description:
      description: Description of server.
      returned: always
      sample: Server
      type: str
    hostname:
      description: Hostname of server.
      returned: always
      sample: my-server-1
      type: str
    id:
      description: The unique identifier of the server.
      returned: always
      sample: x78sdkjds879sd7cx8
      type: str
    location:
      description: Server location ID. Cannot be changed once a server is created.
      returned: always
      sample: PHX
      type: str
    networkConfiguration:
      contains:
        gatewayAddress:
          description:
          - The address of the gateway assigned / to assign to the server.
          - When used as part of request body, IP address has to be part of a private/public
            network or an IP block assigned to this server.
          - Gateway address also has to be assigned on an already deployed resource
            unless the address matches the BMC gateway address in a public network/IP
            block or the force query parameter is true.
          sample: 182.16.0.145
          type: str
        ipBlocksConfiguration:
          contains:
            configurationType:
              description: Determines the approach for configuring IP blocks for the
                server being provisioned.
              sample: PURCHASE_NEW
              type: str
            ipBlocks:
              contains:
                id:
                  description: The IP block's ID.
                  sample: 60473a6115e34466c9f8f083
                  type: str
                vlanId:
                  description: The VLAN on which this IP block has been configured
                    within the network switch.
                  sample: 10
                  type: int
              description:
              - Used to specify the previously purchased IP blocks to assign to this
                server upon provisioning
              - Used alongside the USER_DEFINED configurationType.
              elements: dict
              type: list
          description:
          - The IP blocks to assign to this server. This is an exclusive allocation,
            i.e. the IP blocks cannot be shared with other servers.
          - If IpBlocksConfiguration is not defined, the purchase of a new IP block
            is determined by the networkType field.
          type: dict
        privateNetworkConfiguration:
          contains:
            configurationType:
              description: Determines the approach for configuring private network(s)
                for the server being provisioned.
              sample: USER_DEFINED
              type: str
            privateNetworks:
              contains:
                dhcp:
                  description: Determines whether DHCP is enabled for this server.
                    Should be false if ips is not an empty list. Not supported for
                    proxmox OS.
                  sample: false
                  type: bool
                id:
                  description: The network identifier.
                  sample: 603f3b2cfcaf050643b89a4b
                  type: str
                ips:
                  description: IPs to configure/configured on the server. Should be
                    null or empty list if DHCP is true.
                  elements: str
                  sample:
                  - 10.1.1.1
                  - 10.1.1.2
                  type: list
                statusDescription:
                  description: The status of the network.
                  sample: assigned
                  type: str
              description: The list of private networks this server is member of.
              elements: dict
              type: list
          description: Private network details of bare metal server.
          type: dict
        publicNetworkConfiguration:
          contains:
            publicNetworks:
              contains:
                id:
                  description: The network identifier.
                  sample: 60473c2509268bc77fd06d29
                  type: str
                ips:
                  description: IPs to configure/configured on the server. IPs must
                    be within the network's range.
                  elements: str
                  sample:
                  - 182.16.0.146
                  - 182.16.0.147
                  type: list
                statusDescription:
                  description: The status of the assignment to the network.
                  sample: assigned
                  type: str
              description: The list of public networks this server is member of.
              elements: dict
              type: list
          description: Public network details of bare metal server.
          type: dict
      description: Entire network details of bare metal server.
      type: dict
    networkType:
      description: The type of network configuration for this server.
      returned: always
      sample: PUBLIC_AND_PRIVATE
      type: str
    os:
      description: The server's OS ID used when the server was created.
      returned: always
      sample: ubuntu/bionic
      type: str
    osConfiguration:
      contains:
        cloudInit:
          contains:
            userData:
              description: User data for the cloud-init configuration in base64 encoding.
                NoCloud format is supported.
              type: str
          description: Cloud-init configuration details.
          type: dict
        esxi:
          contains:
            datastoreConfiguration:
              contains:
                datastoreName:
                  description: Datastore name.
                  type: str
              description: Esxi data storage configuration.
              type: dict
          description: Esxi OS configuration.
          type: dict
        installOsToRam:
          description:
          - If true, OS will be installed to and booted from the server's RAM.
          - On restart RAM OS will be lost and the server will not be reachable unless
            a custom bootable OS has been deployed.
          sample: false
          type: bool
        managementAccessAllowedIps:
          description:
          - List of IPs allowed to access the Management UI. Supported in single IP,
            CIDR and range format
          - When undefined, Management UI is disabled. This will only be returned
            in response to provisioning a server.
          elements: str
          sample:
          - 172.217.22.14
          - 10.111.14.40/29
          - 10.111.14.66 - 10.111.14.71
          type: list
        managementUiUrl:
          description: The URL of the management UI which will only be returned in
            response to provisioning a server.
          sample: https://172.217.22.14
          type: str
        netrisController:
          contains:
            hostOs:
              description: Host OS on which the Netris Controller is installed.
              type: str
            netrisUserPassword:
              description:
              - Auto-generated password set for user 'netris' in the web console.
              - The password is not stored and therefore will only be returned in
                response to provisioning a server.
              - Copy and save it for future reference.
              type: str
            netrisWebConsoleUrl:
              description: The URL for the Netris Controller web console. Will only
                be returned in response to provisioning a server.
              type: str
          description: Netris Controller configuration properties.
          type: dict
        netrisSoftgate:
          contains:
            controllerAddress:
              description: IP address or hostname through which to reach the Netris
                Controller.
              type: str
            controllerVersion:
              description: The version of the Netris Controller to connect to.
              type: str
            hostOs:
              description: Host OS on which the Netris Softgate is installed.
              type: str
          description: Netris Softgate configuration properties.
          type: dict
        rootPassword:
          description: Password set for user root on an ESXi server which will only
            be returned in response to provisioning a server.
          sample: MyP@ssw0rd_01
          type: str
        windows:
          contains:
            rdpAllowedIps:
              description:
              - List of IPs allowed for RDP access to Windows OS. Supported in single
                IP, CIDR and range format.
              - When undefined, RDP is disabled. To allow RDP access from any IP use
                0.0.0.0/0.
              - This will only be returned in response to provisioning a server.
              elements: str
              sample:
              - 172.217.22.14
              - 10.111.14.40/29
              - 10.111.14.66 - 10.111.14.71
              type: list
          description: Windows OS configuration properties.
          type: dict
      description: OS specific configuration properties.
      type: dict
    password:
      description: Password set for user Admin on Windows server which will only be
        returned in response to provisioning a server.
      returned: always
      sample: MyP@ssw0rd_01
      type: str
    pricingModel:
      description: The pricing model this server is being billed.
      returned: always
      sample: HOURLY
      type: str
    privateIpAddresses:
      description: Private IP addresses assigned to server.
      returned: always
      sample:
      - 172.16.0.1
      type: list
    provisionedOn:
      description: Date and time when server was provisioned.
      sample: '2021-03-13T20:24:32.491Z'
      type: str
    publicIpAddresses:
      description: Public IP addresses assigned to server.
      returned: always
      sample:
      - 182.16.0.1
      - 183.16.0.1
      type: list
    ram:
      description: A description of the machine RAM.
      returned: always
      sample: 64GB RAM
      type: str
    reservationId:
      description: The reservation reference id if any.
      returned: always
      sample: x78sdkjds879sd7cx8
      type: str
    status:
      description: The status of the server.
      returned: always
      sample: powered-on
      type: str
    storage:
      description: A description of the machine storage.
      returned: always
      sample: 1x 960GB NVMe
      type: str
    storageConfiguration:
      contains:
        rootPartition:
          contains:
            raid:
              description: Software RAID configuration.
              type: str
            size:
              description: The size of the root partition in GB. -1 to use all available
                space.
              type: int
          description: Root partition configuration.
          type: dict
      description: Storage configuration.
      type: dict
    supersededBy:
      description: Unique identifier of the server to which the reservation has been
      sample: 64a539b8d9c2c9ba8424ca31
      type: str
    supersedes:
      description: Unique identifier of the server from which the reservation has
        been transferred.
      sample: 76915b5c85121d411f26e92f
      type: str
    tags:
      contains:
        createdBy:
          description: Who the tag was created by.
          sample: USER
          type: str
        id:
          description: The unique id of the tag.
          sample: 60ffafcdffb8b074c7968dad
          type: str
        isBillingTag:
          description: Whether or not to show the tag as part of billing and invoices
          sample: true
          type: bool
        name:
          description: The name of the tag.
          sample: Environment
          type: str
        value:
          description: The value of the tag assigned to the resource.
          sample: PROD
          type: str
      description: The tags assigned if any.
      returned: always
      type: list
    type:
      description: Server type ID. Cannot be changed once a server is created.
      returned: always
      sample: s1.c1.small
      type: str
  description: The servers information as list
  returned: success
  type: complex