Giter Site home page Giter Site logo

hands-on-ansible's Introduction

Quick notes

Install apache2 (httpd alternative)

  • ansible-doc apt
  • ansible web -i inventory_test -m apt -a "name=apache2 state=present" --become

Apache Service: auto start on boot, state started

  • ansible-doc service
  • ansible web -i inventory_test -m service -a "name=apache2 enabled=yes state=started" --become

Install mysqld

  • ansible db -i inventory_test -m apt -a "name=mysqld state=present" --become

Module

  • setup
ansible all -i inventory_test -m setup -a "filter=ansible_en*" 
ansible all -i inventory_test -m setup -a "filter=ansible_mounts"
ansible all -i inventory_test -m setup -a "filter=ansible_mounts" --tree ./setup

Playbook

  • Plays are ordered sets of tasks to execute against host selections from your inventory
  • Playbook is a file containing one or more plays
  • notify handles from task and handlers
  • condition clause: based on os family (when: ansible_os_family == "Debian"), based on output
  • using template: Jinja2 Engine
ansible-playbook -i hosts.local provision.yml --become

Roles => Making your playbooks reusable

  • Roles are a packages of closely related Ansible content that can be shared more easily than plays alone
  • pre_tasks, post_tasks
  • import_playbook: webservers.yml

Galaxy

ansible-galaxy install -p roles -r requirements.yml
ansible-galaxy init app.test
  • Hosts and Groups
  • Host Variables
  • Group Variables
  • Groups of Groups, and Group Variables

Errors:

Failed to connect to the host via ssh, WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

  • sudo nano ~/.ssh/known_hosts, remove some known_hosts related to these hosts above
  • install sshpass sudo apt-get install sshpass
  • add host_key_checking=False into ansible.cfg
[defaults]
host_key_checking=False
  • tmr solution: specify -u vagrant -k and type password vagrant by default

Vagrant: shared folder error

vagrant plugin install vagrant-vbguest

Questions

hands-on-ansible's People

Contributors

sanhphanvan96 avatar

Stargazers

Nam Nguyen avatar

Watchers

Nam Nguyen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.