- name: Build thing
# localhost is the node running Ansible
# By default, this already is connection local
# exec instead of ssh
hosts: localhost
tasks:
# Assuming make based build scripts
# make module reports not changed if nothing to do
- make:
chdir: /home/builduser/source/thing/
- name: Install thing
hosts: various
tasks:
- copy:
# copy is an action plugin that handles the copy from localhost to remote for yoy
src: /home/builduser/source/thing/output/thing.rpm
dest: /tmp/thing.rpm
# TODO Use custom repo for content management rather than copying one-off packages
- package:
name: /tmp/thing.rpm
您可以创建一个简单的任务来调用
make
命令,localhost
如下所示:这将运行 make 命令并执行 Makefile 中的任何内容。然后在下一个任务中,您可以创建一个复制任务,将结果复制到受管节点。
对于 Ansible,要在一组不同的主机上运行一个东西,请尝试开始一个新的游戏。
尽管您可以在 CI/CD 管道或其他任何方式中运行 Ansible,并且它可以运行任何您喜欢的方式,但 Ansible 作为构建系统并不令人惊奇。它不是面向工件的。