make-Linux学习20201031

20201031,RHCE考前辅导二

(8)创建逻辑卷

  • name: 创建和使用逻辑卷
    host: all
    tasks:
    -block:
    -name: one
    lvol:
    vg:research
    lv: data
    size: 1500

      -name: two
       filesystem:
      	fstype: ext4
      	dev: /dev/research/date
    

    recue:
    -debug:
    msg: could not created xxx
    -name: three
    lvol:
    vg:research
    lv: data
    size: 800
    when: ansible_lvm.vgs.research is defined
    -debug:
    msg: Volume group done not exist
    when: ansible_lvm.vgs.research is undefined

(9)生成主机文件

wget http://materials/hosts.j2 /home/greg/ansible/

vim host.yml

  • name: 生成主机文件
    hosts: dev
    tasks:
    • name: one
      template:
      src: /home/greg/ansible/hosts.j2
      dst: /etc/myhosts

host.j2

{% for host in groups[ ‘all’ ] %}
{{ hostvars[host][ ‘ansible_facts’ ][ ‘default_ipv4’ ][ ‘address’ ] }}
{{ hostvars[host][ ‘ansible_facts’ ][ ‘fqdn’ ] }}
{{ hostvars[host][ ‘ansible_facts’ ][ ‘hostname’ ] }}
{% endfor %}

(10)修改文件内容
vim /home/grep/ansible/issue.yml

  • name: 修改文件内容
    hosts: all
    task:
    • name: one
      shell: “xxxx”
      copy:
      content: ‘Development’
      dest: /etc/issue
      when: “inventory_hostname in groups.dev”
    • name: two
      shell: “xxxx”
      copy:
      content: ‘Test’
      dest: /etc/issue
      when: “inventory_hostname in groups.test”
    • name: three
      shell: “xxxx”
      copy:
      content: ‘Production’
      dest: /etc/issue
      when: “inventory_hostname in groups.prod”

(11)创建web内容目录
vim /home/greg/ansible/webcontent.yml

  • name: 创建web内容目录
    host: all
    task:
    • name: one
      file:
      path: /webdev
      state: directory
      group: webdev
      mode: ‘2775’ 02:14:42疑问为什么是2775
    • name: two
      file:
      src: /webdev
      dst: /var/www/html/webdev
      state: link
    • name: three
      file:
      copy:
      content: “Devlepmet”
      dest: /dev
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值