检查使用列表中的音量
openstack volume list
Run Code Online (Sandbox Code Playgroud)
将状态设置为available
卷
openstack volume set --state available [volume id]
Run Code Online (Sandbox Code Playgroud)
调整音量大小
openstack volume set --size 40 [volume id]
Run Code Online (Sandbox Code Playgroud)
再次检查尺寸和状态
Openstack volume show [volume id]
Run Code Online (Sandbox Code Playgroud)
状态变为in-use
,大小变为 40。它附加到 /dev/vda。
然而,登录虚拟机,使用df -h
检查,没有找到/dev/vda
。
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 1.8G 19G 9% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 17M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
tmpfs 379M 0 379M …
Run Code Online (Sandbox Code Playgroud) 目标服务器:
-bash-4.2$ python -V
Python 2.7.5
-bash-4.2$ pip list | grep psycopg2
psycopg2 (2.8.3)
Run Code Online (Sandbox Code Playgroud)
但如果使用此任务运行 ansible playbook 将失败:
- name: Create repmgr database
postgresql_db:
name: repmgr
become: true
become_user: postgres
Run Code Online (Sandbox Code Playgroud)
错误:
TASK [db : Create repmgr database] ***************************************************************************
fatal: [192.168.0.1]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (psycopg2) on db's Python /usr/bin/python. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python …
Run Code Online (Sandbox Code Playgroud) 使这个任务第一次就能工作:
- name: Initialize the Database
command: /usr/pgsql-9.6/bin/postgresql96-setup initdb
Run Code Online (Sandbox Code Playgroud)
如果第二次运行,会出现错误:
致命:[192.168.0.1]:失败!=> {“更改”:true,“cmd”:[“/usr/pgsql-9.6/bin/postgresql96-setup”,“initdb”],“delta”:“0:00:00.017590”,“结束”: "2019-12-11 06:08:49.999631", "msg": "非零返回码", "rc": 1, "start": "2019-12-11 06:08:49.982041", "stderr ": "", "stderr_lines": [], "stdout": "数据目录不为空!", "stdout_lines": ["数据目录不为空!"]}
如果它已经在服务器上初始化了数据库,如何避免运行此任务?