ansible playbook 笔记

scp -r 65.47.2.75:/root/NDP_CLIENT_4.3* ./
ansible all -m copy -a "src=/root/NDP_CLIENT_4.3.tar.gz dest=/root/ backup=yes owner=root group=root mode=0777"
ansible all -m file -a "path=/opt/NDP state=directory recurse=yes owner=root group=root mode=0777"
ansible all -m copy -a "src=/root/nbp_linux_agent.tar.gz dest=/opt/NDP backup=yes owner=root group=root mode=0777"
ansible all -m shell -a "tar -zxvf /opt/NDP/nbp_linux_agent.tar.gz -C /opt/NDP/"

: << !
ansible all -m file -a "path=/opt/NDP/nbp state=absent"
ansible all -m file -a "path=/opt/NDP/silk-master state=absent"
!

pip install --no-index --find-link=/opt/NDP/pip_deps -r a.txt

: '

ansible all -m copy -a "src=/root/1/setup.py dest=/opt/NDP/silk backup=yes owner=root group=root mode=0777"
ansible all -m copy -a "src=/root/setup.py dest=/opt/NDP/nbp_linux_agent backup=yes owner=root group=root mode=0777"
'



ansible all -m shell -a "scl enable python27 'pip install --no-index --find-links=/opt/NDP/mypackages/pip_deps six==1.10.0 setuptools==20.7 cryptography==1.7.2 paramiko==2.0.2 \
eventlet==0.18.4 simplejson==3.8.1 bson click==6.2 kombu==3.0.33 apscheduler==3.0.6 netifaces==0.10.4 \
ipaddress==1.0.16 funcsigs==1.0.2 requests==2.9.1 redis==2.10.6 dnspython==1.12.0 MySQL-Python==1.2.5'"

ansible all -m shell -a "scl enable python27 bash"
redis==2.10.6
cryptography==1.3.1
pycryptopp==0.6.0.1206569328141510525648634803928199668821045408958
sqlalchemy==1.0.11
paramiko==1.16.1
psutil==3.4.2
dnspython==1.12.0
requests==2.9.1
tornado==4.0.0
pyvmomi==6.5.0.2017.5-1
taskflow==1.32.0
futurist==1.1.0
networkx==1.11
mysqlclient==1.3.7
six==1.10.0
eventlet==0.18.4
simplejson==3.8.1
bson
click==6.2
kombu==3.0.33
netifaces==0.10.4
ipaddress==1.0.16
funcsigs==1.0.2
apscheduler==3.0.6
---
- hosts: all
  remote_user: root

  tasks:
    - name: "mkdir"
      file: path=/etc/yum.repos.d/bak state=directory recurse=yes owner=root group=root mode=0777
    - name: "mv /etc/yum.repos.d/*.repo  /etc/yum.repos.d/bak"
      shell: mv /etc/yum.repos.d/*.repo  /etc/yum.repos.d/bak
    - name: "copy repo"
      copy: src=/etc/yum.repos.d/nbp66.repo dest=/etc/yum.repos.d backup=yes owner=root group=root mode=0777
    - name: "yum clean"
      shell: yum clean all
    - name: "yum repolist enabled"
      shell: yum repolist enabled
    - name: "yum makecache"
      shell: yum makecache
    - name: "install python27-MySQL-python"
      yum: 
        name: 
          - centos-release-scl
          - python27-MySQL-python
          - mysql-devel
          - scl-utils
          - python-pip
          - python-setuptools
        state: present


yum install -y centos-release-scl python27-MySQL-python mysql-devel scl-utils python-pip python-setuptools


ansible all -m shell -a "scl enable python27 'pip install --no-index --find-links=/opt/NDP/mypackages/pip_deps six==1.10.0 setuptools==20.7 cryptography==1.7.2 paramiko==2.0.2 \
eventlet==0.18.4 simplejson==3.8.1 bson click==6.2 kombu==3.0.33 apscheduler==3.0.6 netifaces==0.10.4 \
ipaddress==1.0.16 funcsigs==1.0.2 requests==2.9.1 redis==2.10.6 dnspython==1.12.0 MySQL-Python==1.2.5'"
---
- hosts: all
  remote_user: root

  tasks:
    - name: "copy mypackages"
      copy: src=/root/mypackages.tar.gz dest=/opt/NDP backup=yes owner=root group=root mode=0777
    - name: "tar -zxvf /opt/NDP/mypackages.tar.gz -C /opt/NDP"
      shell: tar -zxvf /opt/NDP/mypackages.tar.gz -C /opt/NDP
    - name: "scl enable python27 bash"
      shell: scl enable python27 bash
    - name: "nbp_linux_agent develop"
      shell: python setup.py develop
      args: 
        chdir: /opt/NDP/nbp_linux_agent
    - name: "silk develop"
      shell: python setup.py develop
      args: 
        chdir: /opt/NDP/silk
# mysql配置
/var/log/silk/nbp-register.log
/etc/nbp/nbp.conf
/etc/nbp/e2fsck.conf

touch.yaml

---
- hosts: all
  remote_user: root

  tasks:
    - name: "create log directory"
      file: path=/var/log/silk state=directory
    - name: "touch nbp-register.log"
      file: path=/var/log/silk/nbp-register.log state=touch
    - name: "create nbp script directory"
      file: path=/etc/nbp state=directory
    - name: "touch /etc/nbp/nbp.conf"
      file: path=/etc/nbp/nbp.conf state=touch
    - name: "touch e2fsck.conf"
      file: path=/etc/nbp/e2fsck.conf state=touch
    - name: "install packages"
      yum: 
        name:
          - screen
          - vim
        state: present

    
    
nbp-register reg_agent --platform linux --type file --uid `uuidgen` --host `hostname` --ip 65.47.16.210 --port 8081

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值