150 lines
3.7 KiB
Plaintext
150 lines
3.7 KiB
Plaintext
{% if grains['kernel'] == 'Linux' %}
|
|
|
|
{% if grains['os'] == 'RedHat' %}
|
|
SELinux for Redhat:
|
|
cmd.run:
|
|
- name: subscription-manager repos --enable=rhel-7-server-extras-rpms
|
|
|
|
Pipons le python:
|
|
pkg.installed:
|
|
{% if grains['osmajorrelease'] == 6 %}
|
|
- name: python27-pip
|
|
{% else %}
|
|
- pkgs:
|
|
- python2-pip
|
|
- scl-utils
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% if grains['os'] == 'Debian' %}
|
|
{% set LURL="deb [arch=amd64] https://download.docker.com/linux/debian " + grains['oscodename']+ " stable" %}
|
|
{% elif grains['os_family'] == 'RedHat' %}
|
|
{% set LURL='https://download.docker.com/linux/centos/' + grains['osmajorrelease']|string + '/$basearch/stable' %}
|
|
{% endif %}
|
|
RemovePreviousDocker:
|
|
pkg.removed:
|
|
- pkgs:
|
|
- docker
|
|
- docker-engine
|
|
- docker.io
|
|
- docker-client
|
|
- docker-client-latest
|
|
- docker-common
|
|
- docker-latest
|
|
- docker-latest-logrotate
|
|
- docker-logrotate
|
|
- docker-selinux
|
|
- docker-engine-selinux
|
|
- docker-engine
|
|
|
|
DockerPrerequisitePackages:
|
|
pkg.installed:
|
|
- pkgs:
|
|
- sudo
|
|
{% if grains['os_family'] == 'Debian' %}
|
|
- apt-transport-https
|
|
- curl
|
|
- ca-certificates
|
|
- gnupg2
|
|
- software-properties-common
|
|
{% elif grains['os_family'] == 'RedHat' %}
|
|
- yum-utils
|
|
- device-mapper-persistent-data
|
|
- lvm2
|
|
{% endif %}
|
|
|
|
Remove Docker-CE Repository:
|
|
file.absent:
|
|
- names:
|
|
- /etc/apt/sources.list.d/docker-ce.list
|
|
- /etc/yum.repos.d/docker-ce.repo
|
|
|
|
DockerCE Repository:
|
|
pkgrepo.managed:
|
|
{% if grains['os'] == 'Debian' %}
|
|
- humanname: Docker-CE Repository
|
|
- name: {{ LURL }}
|
|
- file: /etc/apt/sources.list.d/docker-ce.list
|
|
- keyid: 0EBFCD88
|
|
- keyserver: keyserver.ubuntu.com
|
|
{% elif grains['os_family'] == 'RedHat' %}
|
|
- baseurl: {{ LURL }}
|
|
- humanname: docker-ce-stable
|
|
- name: docker-ce
|
|
- enabled: 1
|
|
- gpgcheck: 1
|
|
- gpgkey: https://download.docker.com/linux/centos/gpg
|
|
{% endif %}
|
|
|
|
Install Docker-CE:
|
|
pkg.installed:
|
|
- pkgs:
|
|
- docker-ce
|
|
- docker-compose
|
|
{% if grains['os'] == 'Debian' %}
|
|
- python-pip
|
|
{% elif grains['os'] == 'CentOS'%}
|
|
- python2-pip
|
|
{% endif %}
|
|
|
|
IwanDocker:
|
|
user.present:
|
|
- name: iwan
|
|
- fullname: Iwan CLEMENT
|
|
- groups:
|
|
- docker
|
|
{% if grains['os'] == 'Debian' %}
|
|
- sudo
|
|
{% elif grains['os_family'] == 'RedHat' %}
|
|
- wheel
|
|
{% endif %}
|
|
|
|
Docker automatic start:
|
|
cmd.run:
|
|
- name: systemctl enable docker
|
|
|
|
Lets start docker:
|
|
cmd.run:
|
|
- name: systemctl start docker
|
|
|
|
{% if grains['os'] == 'RedHat' %}
|
|
Upgrade pip:
|
|
cmd.run:
|
|
{% if grains['osmajorrelease'] == 7 %}
|
|
- name: "pip install --upgrade pip -i {{PIP_REPO_URL}} --trusted-host {{PIP_REPO_SERVER}}"
|
|
- env:
|
|
- LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64:$LD_LIBRARY_PATH
|
|
- PATH=/opt/rh/python27/root/usr/bin:$PATH
|
|
- PKG_CONFIG_PATH=/opt/rh/python27/root/usr/lib64/pkgconfig
|
|
- XDG_DATA_DIRS=/opt/rh/python27/root/usr/share:$XDG_DATA_DIRS
|
|
- X_SCLS='python27 '
|
|
{% else %}
|
|
- name: "pip2.7 install --upgrade pip -i {{PIP_REPO_URL}} --trusted-host {{PIP_REPO_SERVER}}"
|
|
{% endif %}
|
|
- shell: /bin/bash
|
|
{% endif %}
|
|
|
|
Lets install docker with pip:
|
|
pip.installed:
|
|
- name: docker
|
|
# cmd.run:
|
|
# - name: pip install docker
|
|
|
|
Enable Cgroup:
|
|
file.append:
|
|
- name: /etc/defaults/grub
|
|
- text: 'GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"'
|
|
|
|
On rejoue update_grub:
|
|
cmd.run:
|
|
- name: update-grub
|
|
|
|
Recopions Le script de vérification:
|
|
file.managed:
|
|
- source: salt://Scripts/check-config.sh
|
|
- user: root
|
|
- group: root
|
|
- mode: 755
|
|
- name: /root/check-config.sh
|
|
|
|
{% endif %} |