学习的啥也不是

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学习的啥也不是相关的知识,希望对你有一定的参考价值。

啥废话也不说!!

主题一:磁盘格式化,可在线扩容

- hosts: all
  remote_user: root

  tasks:
  - name: pvcreate disk
    shell: pvcreate {{ item }}
    with_items:
    - /dev/vdb
    register: pvcreate_result
    ignore_errors: False

  - name: pvcreate display
    shell: pvdisplay {{ item }}
    with_items:
    - /dev/vdb

  - name: vgcreate disk
    shell: vgcreate -s 4M vg_mascloud {{ item }}
    with_items:
    - /dev/vdb
    register: vgcreate_result
    ignore_errors: False
    when: pvcreate_result | success

  - name: vgcreate display
    shell: vgdisplay {{ item }}
    with_items:
    - vg_mascloud

  - name: lvcreate vg_mascloud
    shell: lvcreate -l +100%FREE -n lv_mascloud {{ item }}
    with_items:
    - vg_mascloud
    register: lvcreate_result
    ignore_errors: False
    when: vgcreate_result | success

  - name: lvcreate display
    shell: lvdisplay /dev/vg_mascloud/{{ item }}
    register: lvcreate_result
    ignore_errors: False
    with_items:
    - lv_mascloud

  - name: mke2fs ext4 lv_mascloud
    shell: mke2fs -t ext4 /dev/vg_mascloud/{{ item }}
    with_items:
    - lv_mascloud
    register: mke2fs_result
    ignore_errors: False
    when: lvcreate_result | success

  - name: check disk format
    shell: blkid /dev/vg_mascloud/{{ item }}
    with_items:
    - lv_mascloud
    when: mke2fs_result | success

主题二:编译安装zabbix_agent3.2

pwd:/etc/ansible/roles/zabbix/tasks
 more main.yml
  - name: Yum Repo
  synchronize: 
   src: /etc/yum.repos.d/
   dest: /etc/yum.repos.d/
   mode: push
  register: synchronize_result
  ignore_errors: False

  - name: Change Yum Mode
    file: path=/etc/yum.repos.d owner=root group=root mode=755 recurse=yes
    when: synchronize_result | success

  - name: Clean Yum
    shell: yum clean all && yum repolist

  - name: Yum Install Rely On Packages
    shell: yum install wget vim -y
    register: yum_result
    ignore_error: False

  - name: Create Zabbix Group
    shell: groupadd zabbix

  - name: Create Zabbix User
    shell: useradd -g zabbix -s /sbin/nologin zabbix

  - name: Mkdir Zabbix Dir
    file: path=/opt/zabbix/{{ item }} state=directory mode=755 owner=root group=root
    with_items:
    - zabbix-agent
    - logs
    - pid

  - name: Get Zabbix Tar  ##在Get Tar包这一步,换成copy或者synchronize比较好,自己测试20台,有4-6台没有get下来
    shell: cd /opt/zabbix && wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.3/zabbix-3.2.3.tar.gz --no-check-certificate
    register: get_result
    ignore_errors: False
    when: yum_result | success

  - name: Tar zabbix
    shell: cd /opt/zabbix/ && tar -xf zabbix-3.2.3.tar.gz 
    register: tar_result
    ignore_errors: False
    when: get_result | success

  - name: make zabbix
    shell: cd /opt/zabbix/zabbix-3.2.3 && ./configure --prefix=/opt/zabbix/zabbix-agent --enable-agent && make && make install
    register: zabbix_make_result
    ignore_errors: False
    when: tar_result | success

  - name: BackUp Zabbix-Agent Configure
    shell: cp /opt/zabbix/zabbix-agent/etc/zabbix_agentd.conf /opt/zabbix/zabbix-agent/etc/zabbix_agentd.conf.bak
    register: back_configtion
    when: zabbix_make_result | success

  - name: Change Zabbix-Agent Configure
    lineinfile: 
      dest: /opt/zabbix/zabbix-agent/etc/zabbix_agentd.conf
      regexp: "{{ item.regexp }}"
      line: "{{ item.line }}"
    with_items:
      - { regexp: ‘^# PidFile=‘,line: "PidFile=/opt/zabbix/pid/zabbix.pid" }
      - { regexp: ‘^LogFile=‘,line: "LogFile=/opt/zabbix/logs/zabbix.log" }
      - { regexp: ‘^# ListenPort=‘,line: "ListenPort=10050" }
      - { regexp: ‘^Server=‘,line: "Server=192.168.1.23" }
      - { regexp: ‘^Hostname=‘,line: "Hostname={{ ansible_hostname }}" }
      - { regexp: ‘^ServerActive=‘,line: "ServerActive=192.168.1.23" }
      - { regexp: ‘^# Timeout=‘,line: "Timeout=30" }
#      - { regexp: ‘^Server=‘,line: "Server={{ ansible_eth0[‘ipv4‘][‘address‘]}}"}
    register: change_configtion
    ignore_errors: False
    when: back_configtion | success

  - name: create zabbix_agent
    shell: cd /opt/zabbix/zabbix-3.2.3/misc/init.d/fedora/core && cp zabbix_agentd /etc/rc.d/init.d/zabbix_agent
    when: change_configtion | success
    register: cp_result
    ignore_errors: False

  - name: change zabbix_agent mode
    shell: chmod +x /etc/rc.d/init.d/zabbix_agent && chkconfig --add zabbix_agent 
    when: cp_result | success

  - name: ln zabbix_agent to local
    shell: ln -sv /opt/zabbix/zabbix-agent/sbin/zabbix_agentd /usr/local/sbin
    when: cp_result | success

  - name: Change ALL Mode
    shell: chown -R zabbix.zabbix /opt/zabbix

pwd:/root/scripts
more zabbix.yml
  - hosts: mgw01
  remote_user: root

  roles:
  - zabbix

在使用zabbix-agent的playbook时,需要确定被监控端服务器的主机名,要不然zabbix-server页面的host主机名会很乱,没有统一性

批量免秘钥、修改主机名,可以查看我之间的博客

以上是关于学习的啥也不是的主要内容,如果未能解决你的问题,请参考以下文章

为啥我的 json.Marshal() 啥也没返回? [复制]

我应该把这段代码放在 Laravel 的啥地方?

啥也不会还做出了机器学习——测试报告

直到遇到到阿里这份资料,我才发现自己是Mysql啥也不是

昨天没更 啥也没做

方法存储在内存中的啥位置?