Wednesday, August 17, 2016

Ansible : Galaxy

http://docs.ansible.com/ansible/galaxy.html

Advanced Control over Role Requirements Files

For more advanced control over where to download roles from, including support for remote repositories, Ansible 1.8 and later support a new YAML format for the role requirements file, which must end in a ‘yml’ extension. It works like this:
ansible-galaxy install -r requirements.yml
The extension is important. If the .yml extension is left off, the ansible-galaxy CLI will assume the file is in the “basic” format and will be confused.
And here’s an example showing some specific version downloads from multiple sources. In one of the examples we also override the name of the role and download it as something different:
 # from galaxy
 - src: yatesr.timezone

 # from GitHub
 - src: https://github.com/bennojoy/nginx

 # from GitHub, overriding the name and specifying a specific tag
 - src: https://github.com/bennojoy/nginx
   version: master
   name: nginx_role

 # from a webserver, where the role is packaged in a tar.gz
 - src: https://some.webserver.example.com/files/master.tar.gz
   name: http-role

 # from Bitbucket
 - src: git+http://bitbucket.org/willthames/git-ansible-galaxy
   version: v1.4

 # from Bitbucket, alternative syntax and caveats
 - src: http://bitbucket.org/willthames/hg-ansible-galaxy
   scm: hg

# from GitLab or other git-based scm
 - src: git@gitlab.company.com:mygroup/ansible-base.git
   scm: git
   version: 0.1.0
As you can see in the above, there are a large amount of controls available to customize where roles can be pulled from, and what to save roles as.
You can also pull down multiple roles from a single source (just make sure that you have a meta/main.yml file at the root level).
meta\main.yml
common-role1\tasks\main.yml
common-role2\tasks\main.yml
For example, if the above common roles are published to a git repo, you can pull them down using:
# multiple roles from the same repo
- src: git@gitlab.company.com:mygroup/ansible-common.git
  name: common-roles
  scm: git
  version: master
You could then use these common roles in your plays
---
- hosts: webservers
  roles:
    - common-roles/common-role1
    - common-roles/common-role2
Roles pulled from galaxy work as with other SCM sourced roles above.
Example:
ansible-galaxy install -r requirements.yml -p /tmp
(requirements.yml contains role specification , version : is the version tag in source control , name: is the role name)

Linux : Snapshot

Create snapshot

lvcreate -s -n snaplvol1 -l 100 vg0/vol1
100 means extents, usually 4M per extents

Then you make system changes.

If changes go well:
Remove snapshot

lvremove -f vg0/snaplvol1

If changes do not go well:
Rollback to snapshot (abort change)

lvconvert --merge vg0/snaplvol1

If this volume is in use, it will be merged during next reboot.


Cancel Snapshot Merge
If at this point, you don't want to rollback to previous snapshot after the next reboot:

Before reboot:

grep description /etc/lvm/archive/vg0*.vg

Find the file with the following output

description = "Created *before* executing 'lvconvert --merge vg0/snaplvol1'"

Then run vgcfgrestore with this file

vgcfgrestore --file /etc/lvm/archive/vg0xxxxxxx.vg

Then reboot

Thursday, August 11, 2016

Linux : force the Linux kernel to crash

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-kdump-configuration-testing.html

force the Linux kernel to crash:

echo 1 > /proc/sys/kernel/sysrq
echo c > /proc/sysrq-trigger

Wednesday, July 27, 2016

OpenCV : project setting in Xcode

Other Linker Flag:
-lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab

Hearder Search Paths: /usr/local/include

Library Search Paths: /usr/local/lib

Monday, July 25, 2016

Selinux : sshd not able to read authorized_keys

Fix:

chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
restore con -R -v /root/.ssh

Wednesday, January 20, 2016

Ansible : install ansible on Ubuntu

$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible

Friday, January 15, 2016

Ansible : Use pip to uprgade Ansible

# pip --proxy https://a.b.c.com:port search ansible
ansible-tower-cli             - A CLI tool for Ansible Tower.
org_wayround_pyeditor         - Simple extansible editor with projects and
                                outline
fabric-tb                     - Based on Fabric, use ansible-like config
                                files.
ansible-docgenerator          - Simple tool for generating ansible role
                                documentation
goodplay                      - goodplay enables you to test your deployments
                                and distributed software infrastructure by
                                reusing your existing knowledge of ansible.
winsible                      - A Faster Ansible (especially on Cygwin)
ansible-role-manager          - A tool for installing and managing Ansible
                                roles, playbooks & modules.
datemike                      - Create Ansible tasks, plays, and playbooks in
                                pure Python
ansible-shell                 - Interactive shell for ansible
ansible-test                  - UNKNOWN
ansible                       - Radically simple IT automation
  INSTALLED: 1.9.4
  LATEST:    2.0.0.2

augploy                       - AUGmentum dePLOYment automation tool, powered
                                by ansible
pytest-ansible                - Plugin for py.test to allow running ansible
ansible-conductor             - Dynamic inventory system for Ansible
snfinv                        - Dynamic ansible inventory for Synnefo IaaS
                                nodes
arpm                          - ansible package manager command line tool
ec2ansible                    - AWS EC2 inventory generator for Ansible
mr.awsome.ansible             - A plugin for mr.awsome providing integration
                                with Ansible.
clc-ansible-module            - Centurylink Cloud Ansible Modules
ansible-inventory-grapher     - Creates graphs representing ansible inventory
ansible-roles                 - Manage ansible roles.
ansible-toolkit               - The missing Ansible tools
ansible_role_apply            - Apply a single Ansible role to host(s) easily
pocker-ansible                - Collection of ansible plugins for docker
                                orchestration using pocker library
messier                       - Test Ansible roles with Vagrant, similar to
                                Test Kitchen
ansible_role_installer        - Install Ansible roles from Git repositories
kapellmeister-ansible         - Ansible Playbook manager.
ansible-cmdb                  - Generate host overview from ansible fact
                                gathering output
ansigenome                    - A tool to help you gather information and
                                manage your Ansible roles.
ansible-flow                  - Workflow tool to speed up interactions with
                                Ansible
ansibleci                     - Ansbile CI tests
galaxy-updater                - Retrieve the latest versions for all of your
                                ansible-galaxy role dependencies.
python-make-ansible           - python-make integration to ansible
ansible-vagrant               - Simple helper to use ansible with vagrant
molecule                      - Vagrant wrapper for testing Ansible roles
ansible-vault                 - R/W an ansible-vault yaml file
ansible-universe              - Ansible role build tool
ansiblator                    - Ansiblator - makes Ansible api more Pythonic
ludolph-ansible               - Ludolph: Ansible plugin
carthage-copy-frameworks      - Keyring integration and local execution
                                wrappers for Ansible
ansible-testing               - Python module and CLI to package and upload
                                python lambda functions to AWS Lambda.
supervisorclusterctl          - supervisorclusterctl is a cmd line tool that
                                allows to control a cluster of processes by
                                utilizing Supervisor and Ansible.
subspace                      - A pragmatic interface to programmatically use
                                Ansible.
tbcli                         - Based on Fabric, use ansible-like config
                                files.
ansiblereporter               - Scripts for ansible to report host output data
dork                          - Docker and ansible based development
                                containers.
mist.ansible                  - Ansible modules for the mist.io service
pyansible                     - A module for interfacing with Ansible Runner
                                and Inventory.
cyclosible                    - Cyclosible is a web-api to manage ansible
tory_client                   - client tools for the tory ansible inventory
ansible-lint                  - checks playbooks for practices and behaviour
                                that could potentially be improved
ploy_ansible                  - Plugin to integrate Ansible with ploy.
playbook_assistant            - Simple utility for Ansible playbook creation
                                and download
ansible-tools                 - Keyring integration and local execution
                                wrappers for Ansible
ansible-windows-compat        - Compatibility library to run Ansible Python
                                modules on a Windows target.
nexus_ansible                 - A random test lib
ansible-roles-graph           - Generate a graph of Ansible role dependencies.
futen                         - Conversion script to Ansible inventory file
                                from OpenSSH configuration
suitable                      - Suitable is a thin wrapper around the Ansible
                                API.
ansible-playbook-debugger     - Debugger for Ansible Playbook
sibl                          - Ansible skeleton generator.
ansible-docgen                - Generate Documentation from Annotated Ansible
                                Playbooks and Roles

# pip list | grep ansible
ansible (1.9.4)

# pip install ansible
Requirement already satisfied (use --upgrade to upgrade): ansible in /usr/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): paramiko in /usr/lib/python2.7/site-packages (from ansible)
Requirement already satisfied (use --upgrade to upgrade): jinja2 in /usr/lib/python2.7/site-packages (from ansible)
Requirement already satisfied (use --upgrade to upgrade): PyYAML in /usr/lib64/python2.7/site-packages (from ansible)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python2.7/site-packages (from ansible)
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.6 in /usr/lib64/python2.7/site-packages (from ansible)
Requirement already satisfied (use --upgrade to upgrade): ecdsa>=0.11 in /usr/lib/python2.7/site-packages (from paramiko->ansible)
Requirement already satisfied (use --upgrade to upgrade): MarkupSafe in /usr/lib/python2.7/site-packages (from jinja2->ansible)

# pip install ansible --upgrade --proxy https://a.b.c.com:port
Collecting ansible
  Downloading ansible-2.0.0.2.tar.gz (1.5MB)
    100% |████████████████████████████████| 1.5MB 208kB/s
Requirement already up-to-date: paramiko in /usr/lib/python2.7/site-packages (from ansible)
Requirement already up-to-date: jinja2 in /usr/lib/python2.7/site-packages (from ansible)
Requirement already up-to-date: PyYAML in /usr/lib64/python2.7/site-packages (from ansible)
Collecting setuptools (from ansible)
  Downloading setuptools-19.2-py2.py3-none-any.whl (463kB)
    100% |████████████████████████████████| 466kB 361kB/s
Requirement already up-to-date: pycrypto>=2.6 in /usr/lib64/python2.7/site-packages (from ansible)
Requirement already up-to-date: ecdsa>=0.11 in /usr/lib/python2.7/site-packages (from paramiko->ansible)
Requirement already up-to-date: MarkupSafe in /usr/lib/python2.7/site-packages (from jinja2->ansible)
Installing collected packages: setuptools, ansible
  Found existing installation: setuptools 18.8
    Uninstalling setuptools-18.8:
      Successfully uninstalled setuptools-18.8
  Found existing installation: ansible 1.9.4
    Uninstalling ansible-1.9.4:
      Successfully uninstalled ansible-1.9.4
  Running setup.py install for ansible
Successfully installed ansible-2.0.0.2 setuptools-19.2

# pip list | grep ansible
ansible (2.0.0.2)