Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
I
init
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
init
Commits
d6cdde7d
Commit
d6cdde7d
authored
Mar 26, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swapon and docker for CentOS
parent
b118634e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
5 deletions
+70
-5
defaults/main.yml
defaults/main.yml
+1
-0
tasks/docker.yml
tasks/docker.yml
+50
-4
tasks/main.yml
tasks/main.yml
+7
-1
tasks/swapon.yml
tasks/swapon.yml
+12
-0
No files found.
defaults/main.yml
View file @
d6cdde7d
...
...
@@ -11,3 +11,4 @@ china_mirror: false
install_docker
:
false
upgrade
:
false
reboot
:
false
pip_executable
:
pip
tasks/docker.yml
View file @
d6cdde7d
...
...
@@ -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"
...
...
tasks/main.yml
View file @
d6cdde7d
...
...
@@ -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
...
...
tasks/swapon.yml
0 → 100644
View file @
d6cdde7d
---
-
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'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment