實際操作測試2 - Docker容器部署
以下是小編在看Udemy前的實作測試
Pull an image
# Install ansible
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
# Install pip and docker-py
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip
sudo pip install docker-py
Edit the playbook
- hosts: localhost
become: true # use root user with sudo
tasks:
- name : Pull Ubuntu Image
docker_image:
name: ubuntu
Run ansible-book docker_pull.yml
[WARNING]: log file at /var/log/ansible.log is not writeable and we cannot create it, aborting
[WARNING]: * Failed to parse /etc/ansible/hosts with yaml plugin: Syntax Error while loading YAML. did not find expected <document start> The error appears to be in '/etc/ansible/hosts': line 45, column 1, but may be elsewhere in
the file depending on the exact syntax problem. The offending line appears to be: [apache] apache2 ansible_host=syrus@192.168.1.108 ansible_port=22 ^ here
[WARNING]: * Failed to parse /etc/ansible/hosts with ini plugin: /etc/ansible/hosts:49: Expected key=value host variable assignment, got: ansible_
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] ****************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Pull Ubuntu Image] ********************************************************************************************************************************************************************************************************************
[WARNING]: The value of the "source" option was determined to be "pull". Please set the "source" option explicitly. Autodetection will be removed in Ansible 2.12.
changed: [localhost]
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Last updated
Was this helpful?