所以我的目录结构大致与此类似
$ tree
.
├── ansible.cfg
├── play.yml
├── roles
│ ├── create_new_user
│ │ ├── defaults
│ │ │ └── main.yml
│ │ └── tasks
│ │ └── main.yml
│ ├── update
│ │ └── tasks
│ │ └── main.yml
└── tests
├── inventory
└── test.yml
在我的.travis.yml
文件
---
sudo: required
dist: trusty
language: python
python: "2.7"
# Doc: https://docs.travis-ci.com/user/customizing-the-build#Build-Matrix
env:
- ANSIBLE_VERSION=2.0.0.0
- ANSIBLE_VERSION=1.9.6
- USER=tasdik
install:
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible-lint; fi
script:
- ansible-playbook -i tests/inventory tests/test.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test.yml -vvvv --skip-tags "update, copy_host_ssh_id"
# check is the user is created or not
- id -u $USER | grep -q "no" && (echo "user not found" && exit 1) || (echo "user found" && exit 0)
我试图跳过roles/create_new_user/tasks/main.yml
但任务不会被跳过。有问题的角色
---
- name: Copy .ssh/id_rsa from host box to the remote box for user {{ username }}
become: true
copy:
src: ~/.ssh/id_rsa.pub
dest: /home/{{ username }}/.ssh/authorized_keys
mode: 0600
owner: "{{ username }}"
group: "{{ username }}"
tags:
- copy_host_ssh_id
tests/test.yml
---
- hosts: localhost
connection: local
become: true
roles:
- {role: ../roles/update}
- {role: ../roles/create_new_user}
Travis build
DOCS :
答案 0 :(得分:1)
删除标记枚举字符串中的空格(由于没有空格,引号也是不必要的):
--skip-tags update,copy_host_ssh_id