安装使用ansible并部署jenkins

ansible 简单使用步骤

  1. 解压ansible
    将ansible_x86_64.tar.gz上传到/data/softs
    执行解压缩 tar zxf ansible_x86_64.tar.gz
    百度云链接: https://pan.baidu.com/s/1GQV8QhNFnw6U5KnuZvPRdA 提取码: e7ab 复制这段内容后打开百度网盘手机App,操作更方便哦

  2. yum 安装
    cd ansible 文件夹,执行 yum -y install *

  3. 关闭公钥认证,编辑 ansible.cfg 文件
    vim /etc/ansible/ansible.cfg
    host_key_checking = False

  4. 生成公钥、私钥
    ssh-keygen -t rsa -b 2048 -P '' -f /root/.ssh/id_rsa

  5. 添加主机信息到 ansible hosts
    路径在/etc/ansible/hosts, 使用已知的账号、密码配置免密钥,例如

[nginx]
local ansible_host=127.0.0.1 ansible_connection=local

192.168.56.11 ansible_ssh_host=192.168.56.11 ansible_ssh_user=root ansible_ssh_pass=123456 ansible_ssh_port=22  
  1. 编写playbook剧本
vim ssh.yml

---
- hosts: all
  gather_facts: no

  tasks:
  - name: install ssh key
    authorized_key: user=root
                    key="{{ lookup('file','/root/.ssh/id_rsa.pub')}}"
                    state=present
  1. 运行playbook
ansible-playbook ssh.yml
  1. ansible 命令参考手册
    http://www.ansible.com.cn/index.html

jenkins的部署

1

posted @ 2022-07-22 14:21  abelkeith  阅读(115)  评论(0)    收藏  举报