repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable state: present filename: docker - name: Install Docker 23.0.1-1 ansible.builtin.apt: name: - docker-ce=5:23.0.1-1~ubuntu.22.04~jammy -docker-ce-cli=5:23.0.1-1~ubuntu.22.04~jammy -...
1)通过命令行来传递变量。 在运行 playbook 的时候,可以通过命令行的方式传递变量,给 playbook 使用,如: ansible-playbook test.yml -e "http_port=8080" 1. 2)在写 playbook 时定义,并且调用。 - hosts: aaa remote_user: root vars: ** //定义变量** - package: apache //变量定义 package - server...
name: Install Docker Compose ansible.builtin.raw: | curl -Lhttps://get.daocloud.io/docker/compose/releases/download/2.27.1/docker-compose-uname -s-uname -m> /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose name: Create symlink for Docker Compose ansible.builtin.file: ...
#卸载旧版本yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine#安装依赖yum install -y yum-utils device-mapper-persistent-data lvm2#添加Repoyum-config-manager --add-repo https://mi...
3.编写playbook --- -hosts: docker remote_user: root tasks:- name:installyum-utilsyum: name=yum-utils state=present-name: add docker repo shell:yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo- name:installdocer-ceyum: ...
下面是一个基本的Ansible Playbook,用于在目标主机上安装Docker: 代码语言:javascript 复制 ---name:Install Dockerhosts:target_hostbecome:truetasks:-name:Install required packagesapt:name:"{{ packages }}"state:presentvars:packages:-apt-transport-https-ca-certificates-curl-gnupg-lsb-release-name:Add Docke...
playbook.yml ---hosts:allbecome:truevars:container_count:4default_container_name:dockerdefault_container_image:ubuntudefault_container_command:sleep 1dtasks:-name:Install aptitudeapt:name:aptitudestate:latestupdate_cache:true-name:Install required system packagesapt:pkg:-apt-transport-https-ca...
以下是一个示例Ansible Playbook,用于启动一个简单的Nginx容器: 代码语言:txt 复制 --- - name: Start Docker container using Ansible hosts: your_target_hosts become: true tasks: - name: Install Docker package apt: name: docker.io state: present ...
pattern playbook要通信的默认主机组 inventory 存放可通信主机的目录 library Ansible默认搜寻模块路径 #用户权限设置 [privilege_escalation] #paramiko插件配置(不是所有情况都启用插件) [paramiko_connection] #ssh连接设置 [ssh_connection] 添加一台机器 ...