top of page

Ansible Overview


Ansible


Ansible is a modern configuration management tool that doesn’t require the use of an agent software on remote nodes. Instead, it uses only SSH and Python to communicate and execute commands on managed servers.

Ansible allows users to manage servers in two different ways: via ad hoc commands, and via playbooks.


Ansible Playbook


An Ansible playbook is a file where users write Ansible code, an organized collection of scripts defining the work of a server configuration. They describe a set of steps in a general IT process or a policy for your remote systems to enforce.


Playbooks consist of one or more plays run in a particular order. A play is an ordered set of tasks run against hosts chosen from your inventory. Plays define the work to be done. Each play contains a set of hosts to configure, and a list of tasks to be executed. There are no standardized plays; an administrator must write each play.


Installation

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html



Sample ansible playbook for install docker container and connection test of deploy ansible nodes from Jenkins.




---
- hosts: all
  become: yes
  gather_facts: yes

  tasks:
    - name: get actual hostname
      debug:
        msg: I am actually {{ ansible_hostname }}

    - name: get ip addr
      debug:
        msg: My core IP address is {{ ansible_facts['eth1']['ipv4']['address'] }}
      when: ansible_facts['eth1'] is defined

    - name: get mgmt ip addr
      debug:
        msg: My management IP address is {{ ansible_facts['eth0']['ipv4']['address'] }}
      when: ansible_facts['eth0'] is defined

    - name: Run a docker container
      docker_container:
        name: hello-world
        image: hello-world:latest
        detach: False
      register: hello_world_container_info

    - name: Print hello_world output
      debug:
        msg: "{{ hello_world_container_info.container.Output }}"

    - name: Remove a docker container
      docker_container:
        name: hello-world
        state: absent

    - name: Remove a docker image
      docker_image:
        name: hello-world
        tag: latest
        state: absent



Kubernetes Cluster - RBAC Examples

Creating Service Account Run the following command to add a new service account called king: $ kubectl create serviceaccount king serviceaccount/king created Find the name of the secret that stores t

Kubernetes - Role-based access control (RBAC)

Kubernetes RBAC The Kubernetes API provides access to sensitive data, including deployment details, persistent storage settings, and secrets. Over the years, the Kubernetes community has provided seve

Kubernetes Cheat Sheet

This page contains a list of commonly used kubectl commands and flags. Kubectl apply - Creating objects # create resource(s) kubectl apply -f ./my-manifest.yaml # create from multiple files kubectl a

Comments


bottom of page