ansible.builtin.one_service (v2.9.27) — module

Deploy and manage OpenNebula services

| "added in version" 2.6 of ansible.builtin"

Authors: Milan Ilic (@ilicmilan)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Manage OpenNebula services

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Instantiate a new service
- one_service:
    template_id: 90
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Print service properties
- debug:
    msg: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Instantiate a new service with specified service_name, service group and mode
- one_service:
    template_name: 'app1_template'
    service_name: 'app1'
    group_id: 1
    mode: '660'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Instantiate a new service with template_id and pass custom_attrs dict
- one_service:
    template_id: 90
    custom_attrs:
      public_network_id: 21
      private_network_id: 26
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Instantiate a new service 'foo' if the service doesn't already exist, otherwise do nothing
- one_service:
    template_id: 53
    service_name: 'foo'
    unique: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Delete a service by ID
- one_service:
    service_id: 153
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Get service info
- one_service:
    service_id: 153
  register: service_info
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Change service owner, group and mode
- one_service:
    service_name: 'app2'
    owner_id: 34
    group_id: 113
    mode: '600'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Instantiate service and wait for it to become RUNNING
-  one_service:
    template_id: 43
    service_name: 'foo1'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Wait service to become RUNNING
- one_service:
    service_id: 112
    wait: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Change role cardinality
- one_service:
    service_id: 153
    role: bar
    cardinality: 5
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Change role cardinality and wait for it to be applied
- one_service:
    service_id: 112
    role: foo
    cardinality: 7
    wait: yes

Inputs

    
mode:
    description:
    - Set permission mode of a service instance in octet format, e.g. C(600) to give owner
      C(use) and C(manage) and nothing to group and others.

role:
    description:
    - Name of the role whose cardinality should be changed

wait:
    default: false
    description:
    - Wait for the instance to reach RUNNING state after DEPLOYING or COOLDOWN state after
      SCALING
    type: bool

force:
    default: false
    description:
    - Force the new cardinality even if it is outside the limits
    type: bool

state:
    choices:
    - present
    - absent
    default: present
    description:
    - C(present) - instantiate a service from a template specified with C(template_id)/C(template_name).
    - C(absent) - terminate an instance of a service specified with C(service_id)/C(service_name).

unique:
    default: false
    description:
    - Setting C(unique=yes) will make sure that there is only one service instance running
      with a name set with C(service_name) when
    - instantiating a service from a template specified with C(template_id)/C(template_name).
      Check examples below.
    type: bool

api_url:
    description:
    - URL of the OpenNebula OneFlow API server.
    - It is recommended to use HTTPS so that the username/password are not transferred
      over the network unencrypted.
    - If not set then the value of the ONEFLOW_URL environment variable is used.

group_id:
    description:
    - ID of the group which will be set as the group of the service

owner_id:
    description:
    - ID of the user which will be set as the owner of the service

service_id:
    description:
    - ID of a service instance that you would like to manage

cardinality:
    description:
    - Number of VMs for the specified role

template_id:
    description:
    - ID of a service template to use to create a new instance of a service

api_password:
    description:
    - Password of the user to login into OpenNebula OneFlow API server. If not set then
      the value of the C(ONEFLOW_PASSWORD) environment variable is used.

api_username:
    description:
    - Name of the user to login into the OpenNebula OneFlow API server. If not set then
      the value of the C(ONEFLOW_USERNAME) environment variable is used.

custom_attrs:
    default: {}
    description:
    - Dictionary of key/value custom attributes which will be used when instantiating
      a new service.

service_name:
    description:
    - Name of a service instance that you would like to manage

wait_timeout:
    default: 300
    description:
    - How long before wait gives up, in seconds

template_name:
    description:
    - Name of service template to use to create a new instance of a service

Outputs

group_id:
  description: service's group id
  returned: success
  sample: 1
  type: int
group_name:
  description: service's group name
  returned: success
  sample: one-users
  type: str
mode:
  description: service's mode
  returned: success
  sample: 660
  type: int
owner_id:
  description: service's owner id
  returned: success
  sample: 143
  type: int
owner_name:
  description: service's owner name
  returned: success
  sample: ansible-test
  type: str
roles:
  description: list of dictionaries of roles, each role is described by name, cardinality,
    state and nodes ids
  returned: success
  sample: '[{"cardinality": 1,"name": "foo","state": "RUNNING","ids": [ 123, 456 ]},
    {"cardinality": 2,"name": "bar","state": "RUNNING", "ids": [ 452, 567, 746 ]}]'
  type: list
service_id:
  description: service id
  returned: success
  sample: 153
  type: int
service_name:
  description: service name
  returned: success
  sample: app1
  type: str
state:
  description: state of service instance
  returned: success
  sample: RUNNING
  type: str