Skip to content

anis016/Ansible-Github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible

Ansible is software that automates software provisioning, configuration management, and application deployment. Wikipedia

For managing the configuration, Ansible uses playbooks. The playbook is the core component of any Ansible configuration. An Ansible playbook contains one or multiple plays, each of which define the work to be done for a configuration on a managed server.

Ansible plays are written in YAML [hdfs_ansible is custom module and copy is ansible module.] Tasks are ordered in List of Dictionaries.

- hosts: ubuntu_hosts
  vars:
      file_name: inventory

  tasks:
    - name: list all the files in the hdfs path
      hdfs_ansible:
        webhdfs_http_url: http://sandbox.hortonworks.com:50070
        hdfsPath: /tmp/
        recurse: False
        command: ls
      register: result_list

    - name: dump output for list
      debug:
        msg: '{{ result_list }}'

    - name: Copy inventory file into /tmp/
      copy: src={{file_name}}
            dest=/tmp/{{file_name}}

Yaml Basic
Playbook Basic
More on ansible playbooks.

HDFS Ansible Module:

Ansible modules are the building blocks for building ansible playbooks. They are small pieces of python code that can be triggered from the yaml in a playbook.

hdfs_ansible is the ansible module for interacting with HDFS. This modules uses the HTTP REST API for interfacing with HDFS.

Resources:

Before running in the kerberos environment, kinit with hdfs user.

kinit -kt /etc/security/keytabs/hdfs.headless.keytab hdfs-sandbox@HORTONWORKS.COM

Once inside the directory, create and start the virual-environment as follows.

virtualenv ansible_venv
source ansible_venv/bin/activate

Install the ansible package

(ansible venv) pip install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org ansible

For running the playbook use the following command

  1. If already in the root user.
ansible-playbook -i src/inventory src/play.yml
  1. In sudo mode and passing the password inline. [not recommended]
ansible-playbook -i src/inventory src/play_apt.yml --user=sayed --extra-vars "ansible_sudo_pass=XXXXXXX"
  1. In sudo mode without passing the password inline.
ansible-playbook -i src/inventory src/play_apt.yml --ask-become-pass

Run playbook using following command:

Resources:

  1. Understanding Ansible:

  2. Custom Ansible Module (using python):

  3. Others:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages