Coder Social home page Coder Social logo

assemble_lineinfile's Introduction

assemble_lineinfile

在ansible服务器修改好配置文件传送到目标机器上
这是一个ansible的action插件
因为经常需要更新配置文件。如果只用ansible自带的包,就要copy+lineinfile。显然这很麻烦并且速度很慢。
所以我参考了assemble与template。直接在ansible服务器上修改完,再传递,测试下来一个task能少10秒。当然如果是局域网,这个差距会小很多。主要是为了书写方便。
用法:

  - name: update file
    assemble_lineinfile:
      src: "/root/base.yaml"
      dest: "/root/base.yaml"
      sub_str: >
               {"#adserverredismaster start":"test\nthis is entry"
               ,"#zkhosts start":"txttest"}
      remote_src: no
      mode: 0777

插件使用的是copy模块
sub_str填写的值为字典
key为regexp值,键值是你你替换成的值

注意:

此替换操作仅限remote_src是False(默认也是False)

assemble_lineinfile's People

Contributors

bestspiders avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.