Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to automate devices using the Ansible CIP collection

January 10, 2023
Josh Swanson
Related topics:
Automation and management
Related products:
Red Hat Ansible Automation Platform

Share:

    During the past few months, Red Hat has collaborated with Rockwell Automation to bring the Red Hat Ansible Automation Platform into a new realm: The control of embedded devices via the Common Industrial Protocol (CIP). This article introduces the value and uses of Ansible Automation Platform's CIP collection, now available in Ansible's Galaxy repository. The development site for this collection is on GitHub.

    Lacking CIP, control over industrial devices has generally been performed by connecting the firmware and programs for a programmable logic controller (PLC) from a laptop over a USB cable. The procedure requires human intervention and isn't particularly scalable.

    Our collaboration with Rockwell Automation established the viability of an Ansible Automation Platform project in this space and brought its power to a whole new class of devices.

    Using configuration files to control devices

    At Ansiblefest 2022, we showcased a demo case from Rockwell Automation, using the Ansible Automation Platform to tell the PLC to toggle an LED light and control the speed and direction of a motor via a variable frequency drive. Figure 1 shows how the computing components connect inside the demo case, containing the LED and a round motor.

    Computer parts and motors are connected within a case.
    Figure 1: Computer parts and motors are connected within a case.

    Figure 2 shows the execution flow of the architecture. Ansible Automation Platform is the automation controller.

    The execution flow of the architecture.
    Figure 2: Ansible Automation Platform controls the PLC, which controls the drive and ultimately the motor.

    The behavior of the motor and LED is automated by adjusting tags (variables) within the PLC program using the new CIP collection. Traditional YAML and natural-language playbooks can make changes against devices. For example, the following code block instructs the PLC to start spinning the motor forward at 1Hz:

    - name: Start motor slowly
      community.cip.ensure_tags:
        tags:
          - name: "Start" # Set ‘Start' to true
            value: True
          - name: "Stop" # Set ‘Stop' to false
            value: False
          - name: "MotorSetPoint" # Set the frequency of the motor
            value: 100
          - name: "isForward" # Set the direction
            value: True

    Figure 3 shows the illuminated LED, and the motor has rotated a bit.

    The light is illuminated and the motor has rotated.
    Figure 3: The light is illuminated and the motor has rotated.

    After the task runs, the frequency shows on the drive.

    Another task can adjust this tag again as follows:

    - name: Speed up
      community.cip.ensure_tags:
        tags:
          - name: "MotorSetPoint"
            value: 5000

    The new tag sets the drive to 50Hz, and the motor spins far more rapidly (Figure 4).

    The round motor is spinning rapidly.
    Figure 4: The round motor is spinning rapidly.

    Real-world use cases for CIP collection

    While adjusting the motor's revolutions per minute (RPMs) and toggling an LED might be a toy application, the CIP collection can manage industrial devices in production environments.

    In the future, PLCs (and ultimately, the industrial systems they control) will become far more composable. Industrial device management can exploit some of the best practices from the DevOps world, such as infrastructure as code and GitOps, to enable agility at a scale not achievable today. New firmware versions that address vulnerabilities can be rolled out globally in a matter of minutes without requiring human intervention at every industrial site. Rapid prototyping can enable the development and testing of PLC programs to add features and functionality, which are immediately deployed to existing manufacturing lines. Also, manufacturing lines can be rapidly reconfigured and redeployed to manufacture new products without taking the line down for an extended period to reconfigure the control systems manually.

    The CIP collection development team

    Developing the CIP collection was a major team effort. We welcome your feedback. Comment below if you have questions, or you can get involved by visiting the GitHub repo issues page. We offer special thanks to the following collection authors from Rockwell Automation and Red Hat:

    • Aaron Neustedter, Rockwell Automation
    • Adam Miller, Red Hat
    • Chris Santiago, Red Hat
    • Matthew Sandoval, Red Hat
    • Josh Swanson, Red Hat
    • Chad Ferman, Red Hat

    Related Posts

    • Using Ansible Galaxy Roles in Ansible Playbook Bundles

    • How to install VMs and Ansible Automation Platform on Mac M1

    • Example of using Ansible to update Container Native Storage

    • How we automate everything at Red Hat Open Innovation Labs

    Recent Posts

    • Assessing AI for OpenShift operations: Advanced configurations

    • OpenShift Lightspeed: Assessing AI for OpenShift operations

    • OpenShift Data Foundation and HashiCorp Vault securing data

    • Axolotl meets LLM Compressor: Fast, sparse, open

    • What’s new for developers in Red Hat OpenShift 4.19

    What’s up next?

    Automation IT

    Automating IT operations lets you do more with what you have, freeing up teams to work on projects that deliver greater business value. In An IT executive's guide to automation, you'll discover the benefits of a long-term transformative automation strategy, explore automation adoption best practices, and more.

    Download the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue