ansible-playbook之修改ssh端口和limits参数控制

简介:

一、描述

   拿到一批机器,需要做首先是修改ssh端口,防火墙配置,以及limits.conf控制文件描述符,进程数,栈大小等。

二、剧本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
     - hosts:  "{{ host }}"
       remote_user:  "{{ user }}"
       gather_facts:  false
 
       tasks:
           - name: Modify  ssh  port 69410
             lineinfile:
                 dest:  /etc/ssh/ {{ item }}
                 regexp:  '^Port 69410'
                 insertafter:  '#Port 22'
                 line:  'Port 69410'
 
             with_items:
                 - sshd_config
                 - ssh_config
             tags:
                 - sshport
 
           - name: Set sysctl  file  limiits
#            pam_limits: domain='*' limit_type=`item`.`limit_type` limit_item=`item`.`limit_item` value=`item`.`value` 
             pam_limits:
                 dest:  "{{ item.dest }}"
                 domain:  '*'
                 limit_type:  "{{ item.limit_type }}"
                 limit_item:  "{{ item.limit_item }}"
                 value:  "{{ item.value }}"
             with_items:
                 - { dest:  '/etc/security/limits.conf' ,limit_type:  'soft' ,limit_item:  'nofile' , value:  '655350'  }
                 - { dest:  '/etc/security/limits.conf' ,limit_type:  'hard' ,limit_item:  'nofile' , value:  '655350' }
                 - { dest:  '/etc/security/limits.conf' ,limit_type:  'soft' ,limit_item:  'nproc' , value:  '102400'  }
                 - { dest:  '/etc/security/limits.conf' ,limit_type:  'hard' ,limit_item:  'nproc' , value:  '102400'  }
                 - { dest:  '/etc/security/limits.conf' ,limit_type:  'soft' ,limit_item:  'sigpending' , value:  '255377'  }
                 - { dest:  '/etc/security/limits.conf' ,limit_type:  'hard' ,limit_item:  'sigpending' , value:  '255377'  }
                 - { dest:  '/etc/security/limits.d/90-nproc.conf' , limit_type:  'soft' ,limit_item:  'nproc' , value:  '262144'  }
                 - { dest:  '/etc/security/limits.d/90-nproc.conf' , limit_type:  'hard' ,limit_item:  'nproc' , value:  '262144'  }
 
             tags:
                 - setlimits









本文转自 zouqingyun 51CTO博客,原文链接:http://blog.51cto.com/zouqingyun/1885014,如需转载请自行联系原作者
目录
相关文章
|
Linux 网络安全
linux端口连通性测试telnet、wget、ssh、curl
linux端口连通性测试telnet、wget、ssh、curl
172 0
|
安全 Linux 网络安全
Centos 6.8下修改SSH服务默认端口,看这一篇就够了
Centos 6.8下修改SSH服务默认端口,看这一篇就够了
272 0
|
运维 应用服务中间件 网络安全
Ansible自动化运维工具之解决SSH连接使用明文密码问题(4)
Ansible自动化运维工具之解决SSH连接使用明文密码问题(4)
166 0
|
2月前
|
网络协议 Ubuntu Linux
解决ssh: connect to host IP port 22: Connection timed out报错(scp传文件指定端口)
解决 `ssh: connect to host IP port 22: Connection timed out` 报错涉及检查 SSH 服务状态、防火墙配置、网络连通性和主机名解析等多个方面。通过逐步排查上述问题,并在 `scp` 命令中正确指定端口,可以有效解决连接超时的问题,确保文件传输的顺利进行。希望本文提供的解决方案能帮助您快速定位并解决该错误。
308 3
|
2月前
|
运维 网络安全
解决ssh: connect to host IP port 22: Connection timed out报错(scp传文件指定端口)
通过这些步骤和方法,您可以有效解决“ssh: connect to host IP port 22: Connection timed out”问题,并顺利使用 `scp`命令传输文件。
1104 7
|
8月前
|
安全 数据挖掘 Shell
SSH安全远程登录与端口转发
**SSH 概述**:SSH 是开发者必备工具,用于安全远程登录及文件传输。本文聚焦SSH的两大功能:**密钥登录**和**端口转发**。
182 0
|
9月前
|
安全 网络安全 数据安全/隐私保护
ansible 建立ssh信任并分发到各个机器
ansible 建立ssh信任并分发到各个机器
185 0
|
6月前
|
网络协议 关系型数据库 MySQL
ssh端口转发
ssh端口转发
|
6月前
|
网络安全
[ansible]建立ssh互信
[ansible]建立ssh互信
|
6月前
|
安全 Linux 网络安全
在Linux中,使用rsync同步数据时,假如采用的是ssh方式,并且目标机器的sshd端端并不是默认的22端口,该如何做?
在Linux中,使用rsync同步数据时,假如采用的是ssh方式,并且目标机器的sshd端端并不是默认的22端口,该如何做?

热门文章

最新文章