Mar 31, 2016

docker unstable package install with openSUSE Leap 42.1 ( + ansible )

20160331

I need install docker unstable version with testbed, so I write the note and ansible playbook with openSUSE Leap 42.1

OS: openSUSE Leap 42.1
Package: docker 1.10.x

docker in openSUSE Leap 42.1 is 1.9.x now.

How to query your docker version?

# zypper   search   -s   --match-exact   docker
Loading repository data...
Reading installed packages...

S | Name   | Type       | Version    | Arch   | Repository               
--+--------+------------+------------+--------+--------------------------
 | docker | package    | 1.9.1-13.1 | x86_64 | openSUSE-Leap-42.1-Update
 | docker | package    | 1.9.1-10.1 | x86_64 | openSUSE-Leap-42.1-Update
 | docker | package    | 1.9.1-7.1  | x86_64 | openSUSE-Leap-42.1-Update
 | docker | package    | 1.9.0-4.1  | x86_64 | openSUSE-Leap-42.1-Update
 | docker | package    | 1.8.2-2.5  | x86_64 | openSUSE-Leap-42.1-Oss   

  • -s - detail, but not much than -v "verbose"
  • --match-exact - match the package name
    • like --match-words ^docker$

I want to install docker with batch mode or non-interactive

First idea
*Use OneClickInstallCLI with .ymp file
Here is the link

But OneClickInstallCLI can't use non-interactive mode -- Give up


Use blow method now
in software.opensuse.org search docker

click Virtualization:container
2016-03-31 10-29-59 的螢幕擷圖.png

In project web page
Click Repositories
You will see The repositories are inherited from the project Virtualization:containers.
Click Virtualization:containers -- > Click Repositories

You could see each version repositories download

2016-03-31 10-41-29 的螢幕擷圖.png

I use Leap 42.1 so click openSUSE_Leap 42.1 link, like

You could see the .repo file in web page

2016-03-31 10-44-31 的螢幕擷圖.png

link is

Use zypper to add repo, key and setup auto refresh

  • --gpg-auto-import-keys  - auto add repo key
  • -f - auto refresh


Check your repos by zypper command


# zypper   repos
#  | Alias                     | Name                                           | Enabled | GPG Check | Refresh
---+---------------------------+------------------------------------------------+---------+-----------+--------
1 | Virtualization_containers | Virtualization:containers (openSUSE_Leap_42.1) | Yes     | ( p) Yes  | Yes    
2 | openSUSE-42.1-0           | openSUSE-42.1-0                                | No      | ----      | No     


# zypper  -n  install  docker
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 7 NEW packages are going to be installed:
 bridge-utils docker docker-image-migrator git-core git-gui gitk perl-Error

The following recommended package was automatically selected:
 docker-image-migrator

7 new packages to install.
Overall download size: 12.9 MiB. Already cached: 0 B. After the operation, additional 59.4 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package docker-image-migrator-1.0.2-7.1.x86_64           


Set up docker start and boot enable


# systemctl   status  docker
docker.service - Docker Application Container Engine
  Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
  Active: inactive (dead)
    Docs: http://docs.docker.com

start docker service
# systemctl  start   docker


# systemctl  status docker
docker.service - Docker Application Container Engine
  Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
  Active: active (running) since Thu 2016-03-31 11:00:58 CST; 2s ago
    Docs: http://docs.docker.com
Main PID: 32272 (docker)
  CGroup: /system.slice/docker.service
          └─32272 /usr/bin/docker daemon -H fd://

Set up boot enable


# systemctl  is-enabled  docker
disabled

enable start at boot
# systemctl  enable  docker


# systemctl  is-enabled   docker
enabled


-------------------------------------------------

I write ansible playbook .yml for insatll with ansible
You could get it at github 

Here is my ansible playbook yml file
# cat   docker_unstable_openSUSELeap42.1_install.yml
---
#########################################################  
# Install docker package and setup boot with unstable repo in openSUSE Leap 42.1
- name: use when conditionals and setup module (facts)
 hosts: all
 tasks:
# 使用 setup moudule 列出 OS 種類
   - name: use setup module to list os distribution
# setup moudle 可以使用 filter 過濾相關內容
     setup: filter=ansible_distribution


#########################################################  

- name: Install docker and run service
# use [dockerUnstable] group to install
 hosts: dockerUnstable
 sudo: True
 tasks:
# Add Virtualization:container project repo
   - name: Add Virutalization:containers repo
     shell: zypper  --gpg-auto-import-keys   addrepo   -f http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_42.1/Virtualization:containers.repo

   - name: Install docker with openSUSE Leap
     zypper: name={{ item }}
     with_items:
       - docker
       - curl
     when: ansible_distribution == "openSUSE Leap"


#-------------------------------------------------------  

   - name: Set docker enable and run
     service: name=docker state=started enabled=yes


Oct 12, 2015

Ansible install with openSUSE 13.2 and Mac

I start to study Ansible cause recently needs.

Ansible is python based, using SSH deploy packages to remote servers, it's like Puppet / Chef / Salt.


Online resource

I study from Oreilly - Ansible up & running
  • code example

    

How to install Ansible

Install Ansible

openSUSE 13.2 ( Most of linux could install ansible now )
Use zypper to query ansible package
# zypper   search   ansible
Loading repository data...
Reading installed packages...

S | Name    | Summary                                                                  | Type      
--+---------+--------------------------------------------------------------------------+-----------
 | ansible | SSH-based configuration management, deployment, and orchestration engine | package   
 | ansible | SSH-based configuration management, deployment, and orchestration engine | srcpackage

Install Ansible
# zypper install  -y  ansible

That's all you need to do :-)

Ansible is clientless, that mean you don't need to install any packages in your remote hosts, it's the most diff with puppet and other tools.
The role is
  • The control machine
    • The one that you use to control remote machines
    • needs to have python 2.6 or later installed.  
  • To manage a server with Ansible
    • Needs to have SSH and Python 2.5 or later installed.
Most linux has python later 2.5 ( Might be python 2.7 ), that's the reason - Nothing to install

What do you need to know? ( From Oreilly book ^^ )
I think the most important point is - you could use ssh and ssh key to execute some commands in remote servers.

What do I need to know?
    • Connect to a remote machine using SSH.
    • Interact with the bash command-line shell (pipes and redirection).
    • Install packages.
    • Use the sudo command.
    • Check and set file permissions.
    • Start and stop services.
    • Set environment variables.
    • Write scripts ( Any language )
  • You don't need to know python to use Ansible unless you want to write your own module.
  • You will need to learn some YAML and Jinja2 to use Ansible.     


That's all today, I will write some Ansible module command next time.

~ enjoy it