/xld-ansible-step-plugin

Use an Ansible Module and Deploy Ansible Roles via Playbook as anXLDeploy step,

Primary LanguagePythonMIT LicenseMIT

XL Deploy Ansible Step plugin

Build Status License: MIT Github All Releases

Preface

This document describes the functionality provided by the XL Deploy Ansible Step plugin..

See the XL Deploy reference manual for background information on XL Deploy and deployment automation concepts.

Overview

The xld-ansible-step-plugin plugin is a XL Deploy plugin that adds capability to use call Ansible module and roles.

Requirements

  • XL Deploy requirements
    • XL Deploy: version 9.5+

Installation

  • Copy the latest JAR file from the releases page into the XL_DEPLOY|RELEASE_SERVER/plugins directory.
  • Restart the XL Deploy server.

Usage

This plugin provides a new & step that can be used by any rules.

This plugin provides a new deployed to deploy ansible roles.

Step Parameters

Parameter Type Description Required
description String Step description Yes
order integer Step order Yes
modulename String Ansible Module Name Yes
moduleargs String Ansible Module Arguments Yes

Example

This XLDeploy type allow to define Ubuntu package to be deployed on a remote host.

 <type type="ansible.AptPackage" extends="udm.BaseDeployed" deployable-type="ansible.AptPackageSpec" container-type="overthere.Host" description="Deploy a system package using ansible">
    <generate-deployable type="ansible.AptPackageSpec" extends="udm.BaseDeployable"/>
    <property name="kind" default="apt"/>
    <property name="repository" required="false"/>
  </type>

The associated rule is using the step using the apt Ansible Module

 <rule name="ansible.AptPackage.CREATE_MODIFY" scope="deployed">
    <conditions>
      <type>ansible.AptPackage</type>
      <operation>CREATE</operation>
      <operation>MODIFY</operation>
    </conditions>
    <steps>
      <ansible>
        <description expression="true">"Install Package %s on %s" % (deployed.name, deployed.container.name)</description>
        <order>55</order>
        <modulename expression="true">deployed.kind</modulename>
        <moduleargs expression="true">{'name':deployed.name, 'state':'present'}</moduleargs>
      </ansible>
    </steps>
  </rule>

The rule to add a new apt ppa repository still using the apt_repository Ansible Module

 <rule name="ansible.AptPackage.CREATE_MODIFY_if_repository" scope="deployed">
    <conditions>
      <type>ansible.AptPackage</type>
      <operation>CREATE</operation>
      <operation>MODIFY</operation>
      <expression>deployed.repository is not None</expression>
    </conditions>
    <steps>
      <ansible>
        <description expression="true">"Add Repository Manager %s on %s" % (deployed.name, deployed.container.name)</description>
        <order>52</order>
        <modulename>apt_repository</modulename>
        <moduleargs expression="true">{'repo':deployed.repository, 'state':'present'}</moduleargs>
      </ansible>
    </steps>
  </rule>

overview

preview

ansible-controler

Step Parameters

Parameter Type Description Required
description String Step description Yes
order integer Step order Yes
roles String Ansible roles Yes
variable String Ansible Variable to pass to the roles Yes

Deploy ansible.Roles

This plugin includes a new CI ansible.Roles allowing to apply a set of Ansible roles to overthere.Hosts. if the Ansible roles includes a generation of YAML devops as code content, the plugin can apply the content to add the provisioned item to the current environment. To trigger this feature, the includeDevOpsAsCodeTask should be the set to True and the roles should includes a template generation, you have an exemple here: template and its usage in the role