- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想知道是否有一种方法使用 Ansible 将文本附加到文件特定部分的行尾,一个示例将阐明我想要做什么:
想象一个这样的文件:
[section01]
path = /home/section01
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
[section02]
path = /home/section02
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
[section03]
path = /home/section03
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
我想在[section02]的host_allow上添加“brazil”来获取这个“新文件”
[section01]
path = /home/section01
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
[section02]
path = /home/section02
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada,brazil
[section03]
path = /home/section03
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
最佳答案
正如 @Dan Farrell 在评论中提到的,您最好生成整个文件,因为部分更新可能不可靠且有问题。
但是您可以使用 ansible templates也能实现这一点。
您使用以下内容创建一个模板文件(例如file.ini
)(为了简洁,删除了其他 block )。该文件将包含完整的 INI 文件内容。
[section02]
path = /home/section02
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = {{allow_hosts}}
然后,在您的剧本中添加一个任务来模板化此文件。
- name: Template INI file
template:
dest: "/path/to/some/file.ini"
src: file.ini
mode: 664
owner: root
group: root
实例化 playbook 时,您可以通过 extra-vars
传递允许的主机的完整列表。
ansible-playbook -i 主机 --extra-vars="allow_hosts=墨西哥、美国、加拿大、巴西"my-playbook.yml
但是,只有当您知道剧本运行时所有允许的主机时,这才对您有用。
关于linux - Ansible 将文本附加到 INI 文件特定部分的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47933480/
PHP 解释器是否首先加载它找到的 php.ini(根据其搜索算法)并停止。还是加载整个 php.ini 层次结构并合并设置? 因此,如果我需要覆盖单个网站的单个设置 - 我需要指定所有值,还是只需要
关于以下形式的归并排序算法: public static void merge(int [] a, int ini, int med, int end){ int [] b = new
如何从另一个 ini 文件解析变量? 在下面的例子中,我想解析 var_a来自 original_configuration.ini并在 new_configuration.ini 使用它 origi
我无法获取 ini 文件中数组的值。 这是 ini 文件: module.name = Core module.version = 1 module.package = 'Core Modules'
编辑 eclipse.ini (OS Ubuntu 12.04 LTS) 后无法保存。如何在 eclipse.ini 文件或任何其他 .ini 文件中进行更改? Eclipse 和 Scala IDE
我目前正在使用 Zend Framework 从事个人项目。我一直无法获得良好的搜索结果,也没有问过我的同事:-/。 我在工作中经常使用 Ant/Phing,你有一个叫做“属性文件”的东西,它们有这个
我想提高我的 mysql 性能。所以我尝试使用 my-large.ini。 首先,我将该文件重命名为 my.ini。然后我在 [mysqld] 下添加了以下行 port=3306 basedir="C
我似乎遇到了一个问题,但感觉它不是一个问题,但我看不到解决方案,所以也许其他人可以。 我正在使用 ini 文件来存储我正在编写的包的配置详细信息。此 ini 文件包含与其他 ini 文件相关的部分。
我正在使用 Java API ini4j解析 ini 文件。我的原始 .ini 文件具有以下键值格式: [section] key=value = 字符周围没有空格。 但是在使用 ini.store(
我有写一段 ini 文件的函数: boolean saveSSVar() { using boost::property_tree::ptree; ptree pt; pt.p
最近我在 ubuntu 16.04 机器上安装了 lamp 和 php-xdebug。我注意到现在我有以下文件 /etc/php/7.0/apache2/conf.d/20-xdebug.ini /e
我正在尝试为我的 Pyramid 项目配置 SQLAlchemy Alembic,我想使用我的 developement.ini(或 production.ini)来配置 Alembic。是否可以指定
我的 FlashBuilder 实例在进行一些繁重的分析时不断崩溃。 必须说,我也在生成对象分配跟踪(全部,而不是默认的 10 个)并大量遍历 GC 路径。 但是我有一种预感,我可以通过允许 Flas
我是网络世界的新手,想知道当服务器默认 php.ini 文件时,自定义 php.ini(我们手动创建并添加到每个目录) 文件,.user.ini 文件由服务器加载/读取? 根据我的概念,这些文件在每次
在创建组件时,我在Joomla的组件目录结构中看到了两个语言文件:.ini和 sys.ini .有什么不同? 最佳答案 虽然@Lodder 本质上是正确的 sys.ini文件实际上有 3 个角色。 它
是否可以加载一个自定义的 .ini 文件来覆盖分发包中乱七八糟的 php.ini? 在 unix 系统上,我相信这可以通过在 /etc/php.d 中放置额外的 ini 文件来实现,但我不确定 IIS
如何在另一个 php.ini 文件中包含一个 php.ini 文件? 最佳答案 我认为您不能从主 php.ini 文件中“包含”.ini 文件。 不过,一个可能的解决方案可能是在编译 PHP 时在配置
您好,我有一个代码,其中使用了几个 INI 文件进行预定义设置。我可以在 INI 文件中使用#ifdef 吗?如果可以,我该如何使用它?如果不是,我如何限制我对 INI 文件的代码编译。例如我有一个宏
下面的代码片段可以编辑 ini 文件,但会将所有 ini 条目替换为小写: config = ConfigParser.RawConfigParser() config.read("test.ini"
我按照 this article 中的说明安装并运行 drush :我的服务器是cloudlinux和cagefs.drupal7 Drush 使用全局 php.ini 文件而不是 drish.ini
我是一名优秀的程序员,十分优秀!