ansible做mysql备份和安全加固

1. mysql备份

A patch adding name=all was added to the mysql_db module on May 12, 2015, so the recommended way to dump all databases is:

# Dumps all databases to hostname.sql
- mysql_db: state=dump name=all target=/tmp/{{ inventory_hostname }}.sql

每个数据库一个文件:

---
# This playbook backups all mysql databases into separate files.

- name: backup mysql
  vars:
    - exclude_db:
      - "Database"
      - "information_schema"
      - "performance_schema"
      - "mysql"
  tasks:
    - name: get db names
      shell: 'mysql -u root -p{{ vault_root_passwd }} -e "show databases;" '
      register: dblist
    - name: backup databases
      mysql_db:
        state: dump
        name: "{{ item }}"
        target: "/tmp/{{ item }}.sql"
        login_user: root
        login_password: "{{ vault_root_passwd }}"
      with_items: "{{ dblist.stdout_lines | difference(exclude_db) }}"

 

2. 安全加固

列一个提纲

  • Change the password for the root account
  • Create and configure a deploy user account
  • Configure ssh public key authentication for the deploy account
  • Add the deploy account to the sudoers list
  • Run apt-get update
  • Run apt-get upgrade
  • Package Installation
  • Configure automatic updates
  • Configure a firewall
  • Install and configure Logwatch
  • Lockdown ssh access

 

 

 

 

参考:

http://www.linuxjournal.com/content/security-hardening-ansible?page=0,3

http://ryaneschinger.com/blog/securing-a-server-with-ansible/

http://docs.openstack.org/developer/openstack-ansible-security/

http://stackoverflow.com/questions/28597029/ansible-how-to-backup-all-mysql-databases

转载于:https://my.oschina.net/u/259976/blog/815576

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值