Infrastructure bundle
This article describes an example of how to create an infrastructure bundle for installing and deploying a hostprovider.
To create an infrastructure bundle, perform the following steps:
-
Create a working directory for the bundle. It should contain the following files:
-
a configuration file, config.yaml or config.yml;
-
Ansible playbooks used to describe and run actions;
-
additional files and directories (HTML files, service information, and so on).
-
An example of a bundle directory structure:
<infrastructure_bundle_name>/ ├── ansible/ -- directory for Ansible that includes Ansible playbook and roles; it is recommended to follow best practices when organizing the structure of internal directories ├── config.yaml -- configuration file └── ... -- additional supporting files and modules
-
Create the config.yaml configuration file, which is a mandatory part of the infrastructure bundle and used by ADCM for creating and managing objects.
-
In the configuration file, add a hostprovider description block. To do this, specify:
-
required properties:
-
name— internal hostprovider name used to refer to the hostprovider; -
type— object type (for a hostprovider, use theprovidervalue); -
version— hostprovider version;
-
-
optional properties:
-
display_name— name of the hostprovider prototype displayed in the ADCM web interface; -
description— description of the hostprovider prototype; -
edition— hostprovider edition; any string value is allowed, for example,communityorenterprise; -
license— path to the license file that a user should accept when creating the hostprovider (the full license text is displayed on the bundle page); -
adcm_min_version— minimum supported ADCM version required to work with the bundle; -
flag_autogeneration— property used to control automatic generation of embedded flags when changing the configuration of hostproviders or hosts; -
venv— Ansible version that will be used when executing hostprovider actions.NOTEOther optional properties that can be defined in the hostprovider description block are listed in the Prototypes overview article.Example of a hostprovider description block:
- type: provider name: SSH Common version: &version '3.0.1-1' description: "Simple ssh hosts" adcm_min_version: "2.2.0"
-
-
-
To enable hostprovider configuration management, add a
configblock in the hostprovider description. The specified hostprovider configuration parameters can be accessed from the Ansible playbook (the parameters are added to the inventory file in{{ vars.provider.config }}). For detailed information on the inventory file structure, refer to Ansible inventory structure.NOTEFor more information on the properties used to define a hostprovider configuration, refer to the config article.Example of a hostprovider configuration parameters block:
config: - name: __main_info type: text default: > The main goal of SSH Common bundle is to quickly and easily manage hosts using Arenadata Cluster Manager. You can specify connection options for existing hosts to use them in cluster deployments. required: false - name: metadata display_name: Metadata type: group subs: - name: admin_ssh_keys display_name: "Ssh keys" type: list description: | List of openssh keys with user@hostname data at the end On create users hostprovider action user list will be parsed from keys and will be created with corresponding keys required: false - name: ansible_ssh_port display_name: "Port" type: string default: "22" description: "SSH port" - name: ansible_user display_name: "Username" type: string default: "root" required: false description: "Username used for SSH connection"where
__main_info— a specialized service configuration parameter that can use an HTML file. -
To execute various hostprovider actions, add an
actionsblock to the hostprovider description. The specified actions will be available in the ADCM web interface on the Hostproviders page.NOTEFor more information on the properties used to describe actions, refer to the actions article.Example of the Create users action’s description block for the hostprovider:
actions: create_users: type: job script_type: ansible script: ansible/common_data/playbooks/create_user.yaml display_name: "Create users" allow_to_terminate: true params: ansible_tags: create_users states: available: *id001NOTEThe specified Ansible playbook can use inventory groups that are generated according to the topology of the hostprovider created by the user. For detailed information about inventory file groups, see Ansible inventory groups.The create_user.yaml file--- - name: "Create users" hosts: all tags: ["create_users"] gather_facts: yes tasks: - include_role: name: create_user loop: "{{ provider.config.metadata.admin_ssh_keys | to_users(additional_users_groups|default(None, true)) }} " loop_control: loop_var: user - name: "Create user" hosts: HOST tags: ["create_user"] gather_facts: yes tasks: - name: "Import user role" import_role: name: create_user vars: user: "{{ job.config }}" -
To describe a hostprovider upgrade from one bundle version to another, add an
upgradeblock to the hostprovider description. The specified upgrade will be available in the Actions column on the Hostproviders page of the ADCM web interface. To do this, specify the following properties in theupgradeblock:-
name— internal identifier of the upgrade operation. -
description— textual description of the upgrade operation. -
display_name— upgrade operation name displayed in the ADCM web interface. -
versions— hostprovider versions allowed for upgrade operation. -
scripts(optional) — sequence of Ansible playbooks executed during the upgrade and displayed on the Jobs page. -
from_edition— list of hostprovider editions permitted for the upgrade operation. -
states— hostprovider states:-
available— list of hostprovider states in which the upgrade operation is allowed. -
on_success— hostprovider state set after a successful upgrade operation. -
on_fail— hostprovider state set after a failed upgrade operation.NOTEFor more information on describing an upgrade operation, refer to the upgrade article.Example of a hostprovider metadata upgrade block:
upgrade: - name: *version description: "That is not a disruptive update. Just metainfo is in upgrade process" versions: min: 1.0 max_strict: *version states: available: any
-
-
-
A hostprovider is intended to create a host. To implement your own host, add the following:
-
block for the description of a host included in the hostprovider similar to the hostprovider description;
-
blocks (directly in the description of a host similar to the description of hostprovider actions and configurations):
-
config— to manage host configuration; -
actions— to perform actions on a host.IMPORTANTNote that you should specify thehostvalue for thetypeproperty.Example of a host description block:
- type: host name: SSH Common Host version: *version actions: ping: display_name: "Check connection" type: job script: ansible/ping.yaml script_type: ansible allow_to_terminate: true states: available: any statuschecker: display_name: "Install statuschecker" params: ansible_tags: statuschecker,instal,enable,start,configure states: available: any type: job script_type: ansible script: ansible/main.yaml allow_to_terminate: true config: __main_info: type: text default: > Please configure <b>Connection address</b> (if DNS does not work), <b>Username</b>, <b>Password</b> or <b>SSH private key</b> (if used instead of a password). And do not forget to run <b>Install statuschecker</b> action. required: false ansible_user: display_name: "Username" type: string default: "root" required: false description: "Username used for SSH connection" ansible_ssh_pass: display_name: "Password" type: password required: false description: "Ansible SSH password"The ping.yaml file--- - name: "Ping connection to host" hosts: "{{ job.hostname }}" tasks: - name: ping ping: # Note: In API v2, host state is managed automatically by ADCM # The adcm_state module has been removed as there is no direct API endpoint # State changes are handled through actions and ADCM internal logicThe main.yaml file--- # Install status_checker - name: "Install status_checker" hosts: "{{ groups.HOST[0] }}" gather_facts: no tasks: - include_role: name: status_checker vars: host_id: '{{ adcm_hostid }}' token: '{{ env.status_api_token }}' service_name: '{{ adcm_hostid }}' checker_type: hosts tags: - statuschecker - install - enable - start - configure
-
-
The final version of the config.yaml configuration file is shown below:
- type: provider
name: SSH Common
version: &version '3.0.1-1'
description: "Simple ssh hosts"
adcm_min_version: "2.2.0"
upgrade:
- name: *version
description: "That is not a disruptive update. Just metainfo is in upgrade process"
versions:
min: 1.0
max_strict: *version
states:
available: any
actions:
create_users:
type: job
script_type: ansible
script: ansible/common_data/playbooks/create_user.yaml
display_name: "Create users"
allow_to_terminate: true
params:
ansible_tags: create_users
states:
available: *id001
config:
- name: __main_info
type: text
default: >
The main goal of SSH Common bundle is to quickly and easily
manage hosts using Arenadata Cluster Manager.
You can specify connection options for existing hosts
to use them in cluster deployments.
required: false
- name: metadata
display_name: Metadata
type: group
subs:
- name: admin_ssh_keys
display_name: "Ssh keys"
type: list
description: |
List of openssh keys with user@hostname data at the end
On create users hostprovider action user list will be parsed from keys
and will be created with corresponding keys
required: false
- name: ansible_ssh_port
display_name: "Port"
type: string
default: "22"
description: "SSH port"
- name: ansible_user
display_name: "Username"
type: string
default: "root"
required: false
description: "Username used for SSH connection"
- type: host
name: SSH Common Host
version: *version
actions:
ping:
display_name: "Check connection"
type: job
script: ansible/ping.yaml
script_type: ansible
allow_to_terminate: true
states:
available: any
statuschecker:
display_name: "Install statuschecker"
params:
ansible_tags: statuschecker,instal,enable,start,configure
states:
available: any
type: job
script_type: ansible
script: ansible/main.yaml
allow_to_terminate: true
config:
__main_info:
type: text
default: >
Please configure <b>Connection address</b> (if DNS does not work), <b>Username</b>,
<b>Password</b> or <b>SSH private key</b> (if used instead of a password).
And do not forget to run <b>Install statuschecker</b> action.
required: false
ansible_user:
display_name: "Username"
type: string
default: "root"
required: false
description: "Username used for SSH connection"
ansible_ssh_pass:
display_name: "Password"
type: password
required: false
description: "Ansible SSH password"