Commit d6cdde7d authored by nanahira's avatar nanahira

swapon and docker for CentOS

parent b118634e
......@@ -11,3 +11,4 @@ china_mirror: false
install_docker: false
upgrade: false
reboot: false
pip_executable: pip
......@@ -2,21 +2,54 @@
set_fact:
mirror_docker: https://mirrors.tuna.tsinghua.edu.cn/docker-ce
when: "china_mirror"
- name: Docker 源公钥
- name: Docker apt 源公钥
become: true
apt_key:
url: '{{mirror_docker}}/linux/{{ ansible_distribution|lower }}/gpg'
- name: Docker 源
when: ansible_os_family == 'Debian'
- name: Docker apt 源
become: true
apt_repository:
repo: 'deb [arch=amd64] {{mirror_docker}}/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable'
filename: docker
- name: 安装 Docker
when: ansible_os_family == 'Debian'
- name: 安装 Docker (apt)
become: true
apt:
name: docker-ce,python-backports-shutil-get-terminal-size,python-backports.ssl-match-hostname,python-pip
update_cache: yes
state: latest
when: ansible_os_family == 'Debian'
- name: docker yum 源
become: true
yum_repository:
name: docker-ce
description: docker-ce
baseurl: '{{mirror_docker}}/linux/{{ ansible_distribution|lower }}/{{ansible_distribution_major_version}}/$basearch/stable'
ip_resolve: 4
gpgkey: '{{mirror_docker}}/linux/{{ ansible_distribution|lower }}/gpg'
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int != 8
- name: docker yum 源 (CentOS 8)
become: true
yum_repository:
name: docker-ce
description: docker-ce
baseurl: '{{mirror_docker}}/linux/centos/7/$basearch/stable'
ip_resolve: 4
gpgkey: '{{mirror_docker}}/linux/7/gpg'
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int == 8
- name: containerd.io
become: true
dnf:
name: '{{mirror_docker}}/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm'
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int == 8
- name: 安装 Docker (yum)
become: true
yum:
name: python3-pip,docker-ce,docker-ce-cli,containerd.io
update_cache: yes
state: latest
when: ansible_os_family == 'RedHat'
- name: docker user group
become: true
user:
......@@ -31,24 +64,36 @@
- name: docker-compose 清理 easy install
become: true
file:
path: /usr/local/lib/python2.7/dist-packages/easy-install.pth
path: '/usr/local/lib/python{{item}}/dist-packages/easy-install.pth'
state: absent
with_items:
- 2.7
- 3.5
- 3.6
- 3.7
- name: 'pip3 for RedHat'
set_fact:
pip_executable: pip3
when: ansible_os_family == 'RedHat'
- name: docker-compose pip
become: true
pip:
name: pip
executable: '{{pip_executable}}'
state: latest
when: "not china_mirror"
- name: docker-compose
become: true
pip:
name: docker-compose
executable: '{{pip_executable}}'
state: latest
when: "not china_mirror"
- name: docker-compose 国内
become: true
pip:
name: pip
executable: '{{pip_executable}}'
state: latest
extra_args: -i https://mirrors.aliyun.com/pypi/simple/
when: "china_mirror"
......@@ -56,6 +101,7 @@
become: true
pip:
name: docker-compose
executable: '{{pip_executable}}'
state: latest
extra_args: -i https://mirrors.aliyun.com/pypi/simple/
when: "china_mirror"
......
......@@ -5,6 +5,12 @@
with_items:
- utility
- sshd_config
- name: detect swap
shell: 'swapon'
register: swap_result
- name: add swap
include_tasks: 'swapon.yml'
when: 'ansible_memtotal_mb < 1024 and not swap_result.stdout'
- name: upgrade
include_tasks: 'upgrade.yml'
when: "upgrade"
......@@ -24,7 +30,7 @@
when: "ansible_os_family == 'RedHat'"
- name: docker
include_tasks: docker.yml
when: "ansible_os_family == 'Debian' and install_docker"
when: "install_docker"
- name: fish
include_tasks: fish.yml
when: "ansible_os_family == 'Debian'" # RedHat has too many problems on fish, so aborted
......
---
- name: make swap
become: true
shell: "fallocate -l 1G /swapfile || dd if=/dev/zero of=/swapfile bs=1M count=1024 ; chmod 600 /swapfile ; mkswap /swapfile ; swapon /swapfile"
args:
creates: /swapfile
- name: swap fstab
become: true
lineinfile:
path: /etc/fstab
line: '/swapfile none swap defaults 0 0'
insertafter: 'EOF'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment