Ansible

You can use Ansible to install and configure Salt Minion on multiple servers:
- name: Install Salt Minion
  hosts: all
  tasks:
    - name: Install Salt Minion
      apt:
        name: salt-minion
        state: present

    - name: Configure Salt Minion
      copy:
        dest: /etc/salt/minion
        content: |
          master: salt-master.example.com
          id: {{ inventory_hostname }}

    - name: Start Salt Minion
      service:
        name: salt-minion
        state: started
        enabled: yes
You can use Ansible to install the Chef client and configure it on multiple servers. Example playbook:
- name: Install Chef Client
  hosts: all
  tasks:
    - name: Download Chef installer
      get_url:
        url: https://packages.chef.io/files/stable/chef/17.10.0/el/7/chef-17.10.0-1.el7.x86_64.rpm
        dest: /tmp/chef.rpm

    - name: Install Chef
      yum:
        name: /tmp/chef.rpm
        state: present

    - name: Create Chef client configuration
      copy:
        dest: /etc/chef/client.rb
        content: |
          chef_server_url "https://chef-server.example.com"
          validation_client_name "my-validator"
Run with:
ansible-playbook -i inventory.ini install_chef.yml
  • Avoid overlapping responsibilities (e.g., don’t let both manage the same config files).
  • Define clear roles (Ansible for provisioning, Puppet for enforcement).
You can use Ansible to install and configure the Puppet agent on multiple servers. Example playbook:
- name: Install Puppet Agent
  hosts: all
  tasks:
    - name: Install Puppet
      apt:
        name: puppet-agent
        state: present

    - name: Start Puppet Agent
      service:
        name: puppet
        state: started
        enabled: yes
  • Use Puppet for long-term configuration enforcement.
  • Use Ansible for orchestration, on-demand tasks, and server provisioning.
  • Combine both for robust automation (e.g., use Ansible to deploy Puppet agents).
Yes! Ansible can complement Puppet by handling ad-hoc tasks, orchestration, and agent bootstrapping, while Puppet continues managing configurations consistently.
  • Install the "Ansible Tower Plugin" in Jenkins.
  • Configure Tower URL and credentials under Manage Jenkins → Configure System.
  • In a Pipeline, trigger an Ansible Tower job:
    ansibleTower(
        towerServer: 'AnsibleTower',
        jobTemplate: 'Deploy App',
        inventory: 'Production'
    )
Use Post-Build Actions in a Freestyle Job:
  • Select "Run Ansible Playbook" after a successful build.
Or, in a Pipeline Script, add:
post {
    success {
        sh 'ansible-playbook -i inventory.ini deploy.yml'
    }
}
You can use extra-vars (-e) in Ansible to pass Jenkins variables:
ansible-playbook -i inventory.ini playbook.yml -e "version=${BUILD_NUMBER}"
Or inside a Jenkins pipeline:
sh 'ansible-playbook -i inventory.ini playbook.yml -e "branch=${GIT_BRANCH}"'

Method 1: Using the "Ansible" Plugin

  1. In Jenkins, create a Freestyle Project.
  2. Under Build Steps, select Invoke Ansible Playbook.
  3. Provide the playbook path (/path/to/playbook.yml).
  4. Add any extra parameters (e.g., -i inventory.ini).

Method 2: Using a Shell Command

  1. Create a Freestyle Project.
  2. Add a Build Step → Execute Shell and run:
ansible-playbook -i inventory.ini playbook.yml

Method 3: Using a Jenkins Pipeline Script

pipeline {
    agent any
    stages {
        stage('Run Ansible') {
            steps {
                sh 'ansible-playbook -i inventory.ini playbook.yml'
            }
        }
    }
}