赤色烙印 发表于 2018-7-30 06:25:32

ansible部署cobbler

#添加新iso镜像脚本  
- hosts: all
  
user: root
  
tasks:
  
    - name: download "{{ NAME }}" from /opt
  
      get_url:
  
      url: "{{ HTTP_URL }}"
  
      dest: /opt/{{ NAME }}
  
#       checksum: md5:c875b0f1dabda14f00a3e261d241f63e #下载iso md5 可做iso验证
  
    - name: mkdir /mnt/{{ ISONAME }} mount -o loop {{ NAME }} /mnt/{{ ISONAME }}
  
      shell: mkdir -p /mnt/{{ ISONAME }} && mount -o loop /opt/{{ NAME }} /mnt/{{ ISONAME }}
  
      ignore_errors: True
  
   #- name: copy to cobbler#拷贝新安装脚本到cobbler 中心请使用绝对路径
  
   #copy: src=/opt/cobbler/roles/cobbler/files/bash dest=/var/www/cobbler/ks_mirror/
  
   # - name: copy to cobbler template
  
   #   template: src=/opt/cobbler/roles/cobbler/templates/{{ ISONAME }}.ks dest=/var/lib/cobbler/kickstarts/{{ ISONAME }}.ks # 安装ks文件有就打开或者部署好web选择
  
   #- name: rep {{ ISONAME }}.ks ip
  
   #shell: sed -i 's/192.168.1.40/{{ IPA }}/' /var/lib/cobbler/kickstarts/{{ ISONAME }}.ks #替换ks文件下载脚本ip地址
  
   #- name:cobbler import ISO
  
   #    shell: cobbler import --path=/mnt/{{ ISONAME }} --name={{ ISONAME }} --kickstart=/var/lib/cobbler/kickstarts{{ ISONAME }}.ks --arch=x86_64
  
   #    ignore_errors: True# 带ks文件导入
  
    - name:cobbler import ISO
  
      shell: cobbler import --path=/mnt/{{ ISONAME }} --name={{ ISONAME }} --arch=x86_64
  
      ignore_errors: True
  
    - name: cobbler profile edit --name={{ ISONAME }}-x86_64 --kopts='net.ifnames=0 biosdevname=0'
  
      shell: cobbler profile edit --name={{ ISONAME }}-x86_64 --kopts='net.ifnames=0 biosdevname=0' #设置网卡eth0 更具需要打开
  
    - name: cobbler sync
  
      shell: cobbler sync
  
      #导入 CentOS-6.8-x86_64-minimal
  
      ansible-playbook -i hosts importiso.yml-verbose --extra-vars "HTTP_URL=http://debian.cn99.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-minimal.iso NAME=CentOS-6.8-x86_64-minimal.iso   ISONAME=CentOS-6.8"
页: [1]
查看完整版本: ansible部署cobbler