如何使用 ansible 和模块 portinstall 安装 FreeBSD 端口?
How install FreeBSD port with ansible and module portinstall?
我需要用 shell:
中的东西构建端口
cd /usr/ports/www/nginx/ && make HTTP_GEOIP=YES BATCH=yes
我可以找到 any document, how run this with ansible module portinstall =(
似乎此操作未在 port_install module The module is part of the ansible-module-extra repository 中实现,这意味着:
These modules are currently shipped with Ansible, but might be shipped separately in the future. They are also mostly maintained by the community. Non-core modules are still fully usable, but may receive slightly lower response rates for issues and pull requests.
由于 BSD(很遗憾)不是很流行,因此实现该功能的可能性不是很高。
但是可以像这样使用 command
模块来解决这些限制:
- name: Build Nginx with geoip.
command: make HTTP_GEOIP=YES BATCH=yes
args:
chdir: /usr/ports/www/nginx/
我建议编写另一个任务来检查系统上安装的端口的状态/版本,并向任务添加一个 when
子句,否则 Ansible 会在每个 运行 时重建端口.
我建议保留自定义构建选项的本地文件,并在 portinstall 之前将其复制到主机。
- name: Copy customized build options
copy: src="{{role_path}}/files/nginx-build-options"
dest="/var/db/ports/www_nginx/options"
- name: Install nginx from the port
portinstall: name=nginx state=present
我想补充一下。不幸的是,建议的解决方法不是幂等的。
- name: Build Nginx with geoip.
command: make HTTP_GEOIP=YES BATCH=yes
args:
chdir: /usr/ports/www/nginx/
这意味着,它将始终报告为 "changed".
我需要用 shell:
中的东西构建端口cd /usr/ports/www/nginx/ && make HTTP_GEOIP=YES BATCH=yes
我可以找到 any document, how run this with ansible module portinstall =(
似乎此操作未在 port_install module The module is part of the ansible-module-extra repository 中实现,这意味着:
These modules are currently shipped with Ansible, but might be shipped separately in the future. They are also mostly maintained by the community. Non-core modules are still fully usable, but may receive slightly lower response rates for issues and pull requests.
由于 BSD(很遗憾)不是很流行,因此实现该功能的可能性不是很高。
但是可以像这样使用 command
模块来解决这些限制:
- name: Build Nginx with geoip.
command: make HTTP_GEOIP=YES BATCH=yes
args:
chdir: /usr/ports/www/nginx/
我建议编写另一个任务来检查系统上安装的端口的状态/版本,并向任务添加一个 when
子句,否则 Ansible 会在每个 运行 时重建端口.
我建议保留自定义构建选项的本地文件,并在 portinstall 之前将其复制到主机。
- name: Copy customized build options
copy: src="{{role_path}}/files/nginx-build-options"
dest="/var/db/ports/www_nginx/options"
- name: Install nginx from the port
portinstall: name=nginx state=present
我想补充一下。不幸的是,建议的解决方法不是幂等的。
- name: Build Nginx with geoip.
command: make HTTP_GEOIP=YES BATCH=yes
args:
chdir: /usr/ports/www/nginx/
这意味着,它将始终报告为 "changed".