自学内容网 自学内容网

如何统计 ansible 中每个 task 的耗时?

使用 Ansible 官方的 profile_tasks、timer 插件统计 ansible 中每个 task 的耗时
在这里插入图片描述

编辑 ansible 的配置文件

vim  /etc/ansible/ansible.cfg

[defaults]
callbacks_enabled = profile_tasks, timer

运行日志

Started by user admin
Loading library sharedlib@master
Attempting to resolve master from remote references...
 > git --version # timeout=10
 > git --version # 'git version 2.39.3'
using GIT_SSH to set credentials jenkins ssh private key
[INFO] Currently running in a labeled security context
[INFO] Currently SELinux is 'enforcing' on the host
 > /usr/bin/chcon --type=ssh_home_t /tmpdata/jenkins-gitclient-ssh7342406090002070521.key
 > git ls-remote -h -- git@gitlab.demo.com:devops/jenkins_sharedlib.git # timeout=10
Found match: refs/heads/master revision commitId
WARNING: ignoring request to compute changelog in clone mode
The recommended git tool is: NONE
using credential jenkins
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository git@gitlab.demo.com:devops/jenkins_sharedlib.git
 > git init /data/jenkins/jobs/test/builds/535/libs/a721707ee1ff11c239a4096505170fb0e0d20a267e6c5768685c6455f5a26efb/root # timeout=10
Fetching upstream changes from git@gitlab.demo.com:devops/jenkins_sharedlib.git
 > git --version # timeout=10
 > git --version # 'git version 2.39.3'
using GIT_SSH to set credentials jenkins ssh private key
[INFO] Currently running in a labeled security context
[INFO] Currently SELinux is 'enforcing' on the host
> git fetch --no-tags --force --progress -- git@gitlab.demo.com:devops/jenkins_sharedlib.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url git@gitlab.demo.com:devops/jenkins_sharedlib.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
Checking out Revision commitId (master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f commitId # timeout=10
Commit message: "add flask docker build and push"
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /data/jenkins/workspace/test
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: git
using credential jenkins
 > git rev-parse --resolve-git-dir /data/jenkins/workspace/test/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@gitlab.demo.com:demo/test.git # timeout=10
Fetching upstream changes from git@gitlab.demo.com:demo/test.git
 > git --version # timeout=10
 > git --version # 'git version 2.39.3'
using GIT_SSH to set credentials jenkins ssh private key
[INFO] Currently running in a labeled security context
[INFO] Currently SELinux is 'enforcing' on the host
 > /usr/bin/chcon --type=ssh_home_t /data/jenkins/workspace/test@tmp/jenkins-gitclient-ssh14822971452146692505.key
 > git fetch --tags --force --progress -- git@gitlab.demo.com:demo/test.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 1c4f6908eaf90407c26610c3232825840a758d35 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 1c4f6908eaf90407c26610c3232825840a758d35 # timeout=10
Commit message: "Merge branch 'feature/gaofan-1018' into 'master'"
 > git rev-list --no-walk 1c4f6908eaf90407c26610c3232825840a758d35 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withCredentials
Masking supported pattern matches of $ANSIBLE_VAULT_ID
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] timeout
Timeout set to expire in 1 hr 0 min
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Prepare)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
INFO: Prepare to check the parameters: (TASK: xxx, ENVIROMENT: dev, BRANCH_TAG: origin/develop)
[Pipeline] echo
INFO: git checkout repositoryUrl git@gitlab.demo.com:demo/test.git with BRANCH_TAG origin/develop
[Pipeline] checkout
The recommended git tool is: git
using credential jenkins
 > git rev-parse --resolve-git-dir /data/jenkins/workspace/test/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@gitlab.demo.com:demo/test.git # timeout=10
Fetching upstream changes from git@gitlab.demo.com:demo/test.git
 > git --version # timeout=10
 > git --version # 'git version 2.39.3'
using GIT_SSH to set credentials jenkins ssh private key
[INFO] Currently running in a labeled security context
[INFO] Currently SELinux is 'enforcing' on the host
 > /usr/bin/chcon --type=ssh_home_t /data/jenkins/workspace/test@tmp/xxx.key
 > git fetch --tags --force --progress -- git@gitlab.demo.com:demo/test.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
Checking out Revision 7e21532cd55804f79fe8991191940e908ac27fab (refs/remotes/origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 7e21532cd55804f79fe8991191940e908ac27fab # timeout=10
Commit message: "Merge branch 'feature/rc-v1.4.1-zhoufeng' of gitlab.demo.com:demo/test into develop"
 > git rev-list --no-walk 7e21532cd55804f79fe8991191940e908ac27fab # timeout=10
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] echo
Running Building TASK deploy-vm: test 1 on https://ci.demo.com/ BRANCH_NAME: null
[Pipeline] script
[Pipeline] {
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] echo
Testing..
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy)
[Pipeline] script
[Pipeline] {
[Pipeline] ansiblePlaybook
[test] $ ansible-playbook /data/jenkins/workspace/test/playbook.yml xxxx
[WARNING]: Invalid characters were found in group names but not replaced, use
-vvvv to see details

PLAY [test1] **********************************************************

TASK [Gathering Facts] *********************************************************
Wednesday 23 October 2024  10:22:51 +0800 (0:00:00.029)       0:00:00.029 ***** 
ok: [test1]

TASK [flask : debug systemd] ***************************************************
Wednesday 23 October 2024  10:22:59 +0800 (0:00:07.961)       0:00:07.991 ***** 
ok: [test1] => {
    "msg": "systemd value is True"
}

TASK [flask : set run env] *****************************************************
Wednesday 23 October 2024  10:22:59 +0800 (0:00:00.038)       0:00:08.029 ***** 
ok: [test1]

TASK [flask : set flask env] ***************************************************
Wednesday 23 October 2024  10:23:02 +0800 (0:00:02.699)       0:00:10.729 ***** 
ok: [test1]

TASK [flask : create /data/flask, /data/flask-baks directory] ******************
Wednesday 23 October 2024  10:23:04 +0800 (0:00:02.515)       0:00:13.245 ***** 
ok: [test1] => (item=/data/flask)
ok: [test1] => (item=/data/flask-baks)

TASK [flask : debug msg] *******************************************************
Wednesday 23 October 2024  10:23:09 +0800 (0:00:05.199)       0:00:18.445 ***** 
ok: [test1] => {
    "msg": "test 1.0 /data/jenkins/workspace/test/src dev python3.10"
}

TASK [flask : check anaconda3 existence] ***************************************
Wednesday 23 October 2024  10:23:09 +0800 (0:00:00.039)       0:00:18.485 ***** 
ok: [test1]

TASK [flask : check miniconda3 existence] **************************************
Wednesday 23 October 2024  10:23:12 +0800 (0:00:02.666)       0:00:21.151 ***** 
ok: [test1]

TASK [flask : pip install flask_cors prometheus-client] ************************
Wednesday 23 October 2024  10:23:14 +0800 (0:00:02.483)       0:00:23.635 ***** 
ok: [test1]

TASK [flask : supervisorctl stop test] ********************************
Wednesday 23 October 2024  10:23:19 +0800 (0:00:04.305)       0:00:27.941 ***** 
fatal: [test1]: FAILED! => {"changed": true, "cmd": ["supervisorctl", "stop", "test"], "delta": "0:00:00.297865", "end": "2024-10-23 10:23:21.789980", "msg": "non-zero return code", "rc": 7, "start": "2024-10-23 10:23:21.492115", "stderr": "", "stderr_lines": [], "stdout": "unix:///run/supervisor/supervisor.sock no such file", "stdout_lines": ["unix:///run/supervisor/supervisor.sock no such file"]}
...ignoring

TASK [flask : debug stop_result] ***********************************************
Wednesday 23 October 2024  10:23:22 +0800 (0:00:02.906)       0:00:30.848 ***** 
ok: [test1] => {
    "stop_result.stdout_lines": [
        "unix:///run/supervisor/supervisor.sock no such file"
    ]
}

TASK [flask : Set SELinux to permissive mode] **********************************
Wednesday 23 October 2024  10:23:22 +0800 (0:00:00.043)       0:00:30.892 ***** 
ok: [test1]

TASK [flask : systemctl stop flask] ********************************************
Wednesday 23 October 2024  10:23:25 +0800 (0:00:03.031)       0:00:33.923 ***** 
changed: [test1]

TASK [flask : debug stop_result] ***********************************************
Wednesday 23 October 2024  10:28:40 +0800 (0:05:15.389)       0:05:49.313 ***** 
ok: [test1] => {
    "stop_result.stdout_lines": "VARIABLE IS NOT DEFINED!"
}

TASK [flask : date command] ****************************************************
Wednesday 23 October 2024  10:28:40 +0800 (0:00:00.041)       0:05:49.355 ***** 
changed: [test1]

TASK [flask : debug dateext] ***************************************************
Wednesday 23 October 2024  10:28:43 +0800 (0:00:02.407)       0:05:51.762 ***** 
ok: [test1] => {
    "dateext.stdout": "2024-10-23.10.28.42"
}

TASK [flask : backup /data/flask/test into /data/flask-baks/test-2024-10-23.10.28.42.tar.gz] ***
Wednesday 23 October 2024  10:28:43 +0800 (0:00:00.046)       0:05:51.809 ***** 
changed: [test1]

TASK [flask : deploy test] ********************************************
Wednesday 23 October 2024  10:28:53 +0800 (0:00:10.072)       0:06:01.882 ***** 
[DEPRECATION WARNING]: The connection's stdin object is deprecated. Call 
display.prompt_until(msg) instead. This feature will be removed in version 
2.19. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
changed: [test1]

TASK [flask : chmod /data/flask/test/] ********************************
Wednesday 23 October 2024  10:28:54 +0800 (0:00:01.517)       0:06:03.400 ***** 
changed: [test1]

TASK [flask : check that the requirements.txt exists] **************************
Wednesday 23 October 2024  10:28:57 +0800 (0:00:02.653)       0:06:06.053 ***** 
ok: [test1]

TASK [flask : pip install requirements.txt] ************************************
Wednesday 23 October 2024  10:28:59 +0800 (0:00:02.471)       0:06:08.525 ***** 
ok: [test1]

TASK [flask : requirements.txt not exists] *************************************
Wednesday 23 October 2024  10:29:05 +0800 (0:00:06.091)       0:06:14.616 ***** 
skipping: [test1]

TASK [flask : debug pip_install_result] ****************************************
Wednesday 23 October 2024  10:29:05 +0800 (0:00:00.041)       0:06:14.657 ***** 
ok: [test1] => {
    "pip_install_result.stdout_lines": [
        "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://developer:****@nexus.demo.com/repository/pypi/simple",
        "Requirement already satisfied: cachetools==5.3.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 1)) (5.3.2)",
        "Requirement already satisfied: DBUtils==3.0.3 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 2)) (3.0.3)",
        "Requirement already satisfied: Flask==3.0.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 3)) (3.0.1)",
        "Requirement already satisfied: Flask-APScheduler==1.12.4 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 4)) (1.12.4)",
        "Requirement already satisfied: SQLAlchemy==2.0.25 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 5)) (2.0.25)",
        "Requirement already satisfied: flake8==7.1.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 6)) (7.1.0)",
        "Requirement already satisfied: flask_cors==4.0.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 7)) (4.0.0)",
        "Requirement already satisfied: openpyxl==3.1.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 8)) (3.1.2)",
        "Requirement already satisfied: PyJWT==1.7.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 9)) (1.7.0)",
        "Requirement already satisfied: PyMySQL==1.1.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 10)) (1.1.0)",
        "Requirement already satisfied: pyxxl==0.3.5 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 11)) (0.3.5)",
        "Requirement already satisfied: redis==5.0.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 12)) (5.0.0)",
        "Requirement already satisfied: Requests==2.31.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 13)) (2.31.0)",
        "Requirement already satisfied: rqdatac==2.11.6.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 14)) (2.11.6.1)",
        "Requirement already satisfied: Werkzeug==3.0.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 15)) (3.0.1)",
        "Requirement already satisfied: sentry-sdk==2.2.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from sentry-sdk[flask]==2.2.0->-r /data/flask/test/requirements.txt (line 16)) (2.2.0)",
        "Requirement already satisfied: numpy==1.26.3 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 17)) (1.26.3)",
        "Requirement already satisfied: pandas==2.1.4 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 18)) (2.1.4)",
        "Requirement already satisfied: singleton-decorator==1.0.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 19)) (1.0.0)",
        "Requirement already satisfied: pydantic==2.8.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 20)) (2.8.2)",
        "Requirement already satisfied: psycopg2==2.9.9 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 22)) (2.9.9)",
        "Requirement already satisfied: cos-python-sdk-v5==1.9.30 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 23)) (1.9.30)",
        "Requirement already satisfied: xlrd==2.0.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 24)) (2.0.1)",
        "Requirement already satisfied: chardet==4.0.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 25)) (4.0.0)",
        "Requirement already satisfied: exchangelib==5.4.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 26)) (5.4.2)",
        "Requirement already satisfied: retrying==1.3.4 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 27)) (1.3.4)",
        "Requirement already satisfied: pyAesCrypt==6.1.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 28)) (6.1.1)",
        "Requirement already satisfied: concurrent-log-handler==0.9.25 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 29)) (0.9.25)",
        "Requirement already satisfied: hvac==2.3.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 30)) (2.3.0)",
        "Requirement already satisfied: PyDispatcher==2.0.7 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 31)) (2.0.7)",
        "Requirement already satisfied: python-dateutil==2.9.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from -r /data/flask/test/requirements.txt (line 32)) (2.9.0)",
        "Requirement already satisfied: Jinja2>=3.1.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Flask==3.0.1->-r /data/flask/test/requirements.txt (line 3)) (3.1.4)",
        "Requirement already satisfied: itsdangerous>=2.1.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Flask==3.0.1->-r /data/flask/test/requirements.txt (line 3)) (2.2.0)",
        "Requirement already satisfied: click>=8.1.3 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Flask==3.0.1->-r /data/flask/test/requirements.txt (line 3)) (8.1.7)",
        "Requirement already satisfied: blinker>=1.6.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Flask==3.0.1->-r /data/flask/test/requirements.txt (line 3)) (1.6.2)",
        "Requirement already satisfied: apscheduler<4.0.0,>=3.2.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Flask-APScheduler==1.12.4->-r /data/flask/test/requirements.txt (line 4)) (3.10.4)",
        "Requirement already satisfied: typing-extensions>=4.6.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from SQLAlchemy==2.0.25->-r /data/flask/test/requirements.txt (line 5)) (4.11.0)",
        "Requirement already satisfied: greenlet!=0.4.17 in /data/pyenv/python3.10/lib/python3.10/site-packages (from SQLAlchemy==2.0.25->-r /data/flask/test/requirements.txt (line 5)) (3.0.1)",
        "Requirement already satisfied: mccabe<0.8.0,>=0.7.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from flake8==7.1.0->-r /data/flask/test/requirements.txt (line 6)) (0.7.0)",
        "Requirement already satisfied: pycodestyle<2.13.0,>=2.12.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from flake8==7.1.0->-r /data/flask/test/requirements.txt (line 6)) (2.12.0)",
        "Requirement already satisfied: pyflakes<3.3.0,>=3.2.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from flake8==7.1.0->-r /data/flask/test/requirements.txt (line 6)) (3.2.0)",
        "Requirement already satisfied: et-xmlfile in /data/pyenv/python3.10/lib/python3.10/site-packages (from openpyxl==3.1.2->-r /data/flask/test/requirements.txt (line 8)) (1.1.0)",
        "Requirement already satisfied: aiofiles<23.0.0,>=22.1.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from pyxxl==0.3.5->-r /data/flask/test/requirements.txt (line 11)) (22.1.0)",
        "Requirement already satisfied: aiohttp<4.0.0,>=3.8.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from pyxxl==0.3.5->-r /data/flask/test/requirements.txt (line 11)) (3.9.5)",
        "Requirement already satisfied: async-timeout>=4.0.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from redis==5.0.0->-r /data/flask/test/requirements.txt (line 12)) (4.0.3)",
        "Requirement already satisfied: charset-normalizer<4,>=2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Requests==2.31.0->-r /data/flask/test/requirements.txt (line 13)) (3.3.2)",
        "Requirement already satisfied: idna<4,>=2.5 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Requests==2.31.0->-r /data/flask/test/requirements.txt (line 13)) (3.7)",
        "Requirement already satisfied: urllib3<3,>=1.21.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Requests==2.31.0->-r /data/flask/test/requirements.txt (line 13)) (2.2.2)",
        "Requirement already satisfied: certifi>=2017.4.17 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Requests==2.31.0->-r /data/flask/test/requirements.txt (line 13)) (2024.7.4)",
        "Requirement already satisfied: brotli in /data/pyenv/python3.10/lib/python3.10/site-packages (from rqdatac==2.11.6.1->-r /data/flask/test/requirements.txt (line 14)) (1.1.0)",
        "Requirement already satisfied: msgpack>=0.5.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from rqdatac==2.11.6.1->-r /data/flask/test/requirements.txt (line 14)) (1.0.8)",
        "Requirement already satisfied: six in /data/pyenv/python3.10/lib/python3.10/site-packages (from rqdatac==2.11.6.1->-r /data/flask/test/requirements.txt (line 14)) (1.16.0)",
        "Requirement already satisfied: zstandard in /data/pyenv/python3.10/lib/python3.10/site-packages (from rqdatac==2.11.6.1->-r /data/flask/test/requirements.txt (line 14)) (0.23.0)",
        "Requirement already satisfied: orjson in /data/pyenv/python3.10/lib/python3.10/site-packages (from rqdatac==2.11.6.1->-r /data/flask/test/requirements.txt (line 14)) (3.10.6)",
        "Requirement already satisfied: python-rapidjson in /data/pyenv/python3.10/lib/python3.10/site-packages (from rqdatac==2.11.6.1->-r /data/flask/test/requirements.txt (line 14)) (1.18)",
        "Requirement already satisfied: MarkupSafe>=2.1.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from Werkzeug==3.0.1->-r /data/flask/test/requirements.txt (line 15)) (2.1.3)",
        "Requirement already satisfied: pytz>=2020.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from pandas==2.1.4->-r /data/flask/test/requirements.txt (line 18)) (2024.1)",
        "Requirement already satisfied: tzdata>=2022.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from pandas==2.1.4->-r /data/flask/test/requirements.txt (line 18)) (2023.3)",
        "Requirement already satisfied: annotated-types>=0.4.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from pydantic==2.8.2->-r /data/flask/test/requirements.txt (line 20)) (0.7.0)",
        "Requirement already satisfied: pydantic-core==2.20.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from pydantic==2.8.2->-r /data/flask/test/requirements.txt (line 20)) (2.20.1)",
        "Requirement already satisfied: xmltodict in /data/pyenv/python3.10/lib/python3.10/site-packages (from cos-python-sdk-v5==1.9.30->-r /data/flask/test/requirements.txt (line 23)) (0.13.0)",
        "Requirement already satisfied: crcmod in /data/pyenv/python3.10/lib/python3.10/site-packages (from cos-python-sdk-v5==1.9.30->-r /data/flask/test/requirements.txt (line 23)) (1.7)",
        "Requirement already satisfied: pycryptodome in /data/pyenv/python3.10/lib/python3.10/site-packages (from cos-python-sdk-v5==1.9.30->-r /data/flask/test/requirements.txt (line 23)) (3.20.0)",
        "Requirement already satisfied: cached-property in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (1.5.2)",
        "Requirement already satisfied: defusedxml>=0.6.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (0.7.1)",
        "Requirement already satisfied: dnspython>=2.2.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (2.6.1)",
        "Requirement already satisfied: isodate in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (0.6.1)",
        "Requirement already satisfied: lxml>3.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (5.2.2)",
        "Requirement already satisfied: oauthlib in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (3.2.2)",
        "Requirement already satisfied: pygments in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (2.18.0)",
        "Requirement already satisfied: requests-ntlm>=0.2.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (1.3.0)",
        "Requirement already satisfied: requests-oauthlib in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (2.0.0)",
        "Requirement already satisfied: tzlocal in /data/pyenv/python3.10/lib/python3.10/site-packages (from exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (5.2)",
        "Requirement already satisfied: cryptography in /data/pyenv/python3.10/lib/python3.10/site-packages (from pyAesCrypt==6.1.1->-r /data/flask/test/requirements.txt (line 28)) (43.0.0)",
        "Requirement already satisfied: portalocker>=1.6.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from concurrent-log-handler==0.9.25->-r /data/flask/test/requirements.txt (line 29)) (2.10.1)",
        "Requirement already satisfied: aiosignal>=1.1.2 in /data/pyenv/python3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.1->pyxxl==0.3.5->-r /data/flask/test/requirements.txt (line 11)) (1.3.1)",
        "Requirement already satisfied: attrs>=17.3.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.1->pyxxl==0.3.5->-r /data/flask/test/requirements.txt (line 11)) (23.2.0)",
        "Requirement already satisfied: frozenlist>=1.1.1 in /data/pyenv/python3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.1->pyxxl==0.3.5->-r /data/flask/test/requirements.txt (line 11)) (1.4.1)",
        "Requirement already satisfied: multidict<7.0,>=4.5 in /data/pyenv/python3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.1->pyxxl==0.3.5->-r /data/flask/test/requirements.txt (line 11)) (6.0.5)",
        "Requirement already satisfied: yarl<2.0,>=1.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.1->pyxxl==0.3.5->-r /data/flask/test/requirements.txt (line 11)) (1.9.4)",
        "Requirement already satisfied: pyspnego>=0.4.0 in /data/pyenv/python3.10/lib/python3.10/site-packages (from requests-ntlm>=0.2.0->exchangelib==5.4.2->-r /data/flask/test/requirements.txt (line 26)) (0.11.1)",
        "Requirement already satisfied: cffi>=1.12 in /data/pyenv/python3.10/lib/python3.10/site-packages (from cryptography->pyAesCrypt==6.1.1->-r /data/flask/test/requirements.txt (line 28)) (1.16.0)",
        "Requirement already satisfied: pycparser in /data/pyenv/python3.10/lib/python3.10/site-packages (from cffi>=1.12->cryptography->pyAesCrypt==6.1.1->-r /data/flask/test/requirements.txt (line 28)) (2.22)"
    ]
}

TASK [flask : Check if app-role file exists] ***********************************
Wednesday 23 October 2024  10:29:06 +0800 (0:00:00.042)       0:06:14.700 ***** 
ok: [test1]

TASK [flask : Print the result if app-role file does not exist] ****************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:02.549)       0:06:17.250 ***** 
skipping: [test1]

TASK [flask : systemd enable supervisord] **************************************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.034)       0:06:17.285 ***** 
skipping: [test1]

TASK [flask : start supervisord] ***********************************************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.034)       0:06:17.320 ***** 
skipping: [test1]

TASK [flask : write test and 1.0 to supervisord config file] **********
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.038)       0:06:17.358 ***** 
skipping: [test1]

TASK [flask : supervisorctl update] ********************************************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.034)       0:06:17.392 ***** 
skipping: [test1]

TASK [flask : debug update_result] *********************************************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.034)       0:06:17.427 ***** 
skipping: [test1]

TASK [flask : supervisorctl start test] *******************************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.037)       0:06:17.464 ***** 
skipping: [test1]

TASK [flask : debug start_result] **********************************************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.035)       0:06:17.500 ***** 
skipping: [test1]

TASK [flask : fail if start_result.rc is not 0] ********************************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.037)       0:06:17.537 ***** 
skipping: [test1]

TASK [flask : copy flask logrotate config] *************************************
Wednesday 23 October 2024  10:29:08 +0800 (0:00:00.036)       0:06:17.574 ***** 
ok: [test1]

TASK [flask : copy flask.service] **********************************************
Wednesday 23 October 2024  10:29:12 +0800 (0:00:03.828)       0:06:21.402 ***** 
ok: [test1]

TASK [flask : systemd enable flask service] ************************************
Wednesday 23 October 2024  10:29:16 +0800 (0:00:03.861)       0:06:25.264 ***** 
ok: [test1]

TASK [flask : start flask service] *********************************************
Wednesday 23 October 2024  10:29:19 +0800 (0:00:02.889)       0:06:28.153 ***** 
changed: [test1]

TASK [flask : systemctl status flask] ******************************************
Wednesday 23 October 2024  10:29:29 +0800 (0:00:09.970)       0:06:38.124 ***** 
changed: [test1]

TASK [flask : debug flask_status] **********************************************
Wednesday 23 October 2024  10:29:44 +0800 (0:00:14.606)       0:06:52.731 ***** 
ok: [test1] => {
    "flask_status": {
        "changed": true,
        "cmd": [
            "systemctl",
            "status",
            "flask"
        ],
        "delta": "0:00:00.140465",
        "end": "2024-10-23 10:29:41.441023",
        "failed": false,
        "msg": "",
        "rc": 0,
        "start": "2024-10-23 10:29:41.300558",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "● flask.service - Flask Application Server\n   Loaded: loaded (/etc/systemd/system/flask.service; enabled; vendor preset: disabled)\n   Active: active (running) since Wed 2024-10-23 10:29:27 CST; 14s ago\n Main PID: 901148 (uwsgi)\n   Status: \"uWSGI is ready\"\n    Tasks: 36 (limit: 22924)\n   Memory: 1.4G\n   CGroup: /system.slice/flask.service\n           ├─901148 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini\n           ├─901176 python xxl_job_executor.py\n           ├─901177 python consumer_init_executor.py 1\n           ├─901178 python consumer_init_executor.py 2\n           ├─901179 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini\n           ├─901180 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini\n           ├─901181 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini\n           ├─901182 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini\n           └─901183 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini\n\nOct 23 10:29:21 test1 systemd[1]: Starting Flask Application Server...\nOct 23 10:29:27 test1 systemd[1]: Started Flask Application Server.",
        "stdout_lines": [
            "● flask.service - Flask Application Server",
            "   Loaded: loaded (/etc/systemd/system/flask.service; enabled; vendor preset: disabled)",
            "   Active: active (running) since Wed 2024-10-23 10:29:27 CST; 14s ago",
            " Main PID: 901148 (uwsgi)",
            "   Status: \"uWSGI is ready\"",
            "    Tasks: 36 (limit: 22924)",
            "   Memory: 1.4G",
            "   CGroup: /system.slice/flask.service",
            "           ├─901148 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini",
            "           ├─901176 python xxl_job_executor.py",
            "           ├─901177 python consumer_init_executor.py 1",
            "           ├─901178 python consumer_init_executor.py 2",
            "           ├─901179 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini",
            "           ├─901180 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini",
            "           ├─901181 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini",
            "           ├─901182 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini",
            "           └─901183 /home/work/.conda/envs/python3.10/bin/uwsgi --ini /data/flask/test/uwsgi.ini",
            "",
            "Oct 23 10:29:21 test1 systemd[1]: Starting Flask Application Server...",
            "Oct 23 10:29:27 test1 systemd[1]: Started Flask Application Server."
        ]
    }
}

TASK [flask : fail if flask service status is not active] **********************
Wednesday 23 October 2024  10:29:44 +0800 (0:00:00.063)       0:06:52.794 ***** 
skipping: [test1]

PLAY RECAP *********************************************************************
test1             : ok=29   changed=8    unreachable=0    failed=0    skipped=11   rescued=0    ignored=1   

Wednesday 23 October 2024  10:29:44 +0800 (0:00:00.089)       0:06:52.884 ***** 
=============================================================================== 
flask : systemctl stop flask ------------------------------------------ 315.39s
flask : systemctl status flask ----------------------------------------- 14.61s
flask : backup /data/flask/test into /data/flask-baks/test-2024-10-23.10.28.42.tar.gz -- 10.07s
flask : start flask service --------------------------------------------- 9.97s
Gathering Facts --------------------------------------------------------- 7.96s
flask : pip install requirements.txt ------------------------------------ 6.09s
flask : create /data/flask, /data/flask-baks directory ------------------ 5.20s
flask : pip install flask_cors prometheus-client ------------------------ 4.31s
flask : copy flask.service ---------------------------------------------- 3.86s
flask : copy flask logrotate config ------------------------------------- 3.83s
flask : Set SELinux to permissive mode ---------------------------------- 3.03s
flask : supervisorctl stop test -------------------------------- 2.91s
flask : systemd enable flask service ------------------------------------ 2.89s
flask : set run env ----------------------------------------------------- 2.70s
flask : check anaconda3 existence --------------------------------------- 2.67s
flask : chmod /data/flask/test/ -------------------------------- 2.65s
flask : Check if app-role file exists ----------------------------------- 2.55s
flask : set flask env --------------------------------------------------- 2.52s
flask : check miniconda3 existence -------------------------------------- 2.48s
flask : check that the requirements.txt exists -------------------------- 2.47s
Playbook run took 0 days, 0 hours, 6 minutes, 52 seconds
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

实际效果

profile_tasks 插件日志

TASK [flask : systemctl stop flask] ********************************************
Wednesday 23 October 2024  10:23:25 +0800 (0:00:03.031)       0:00:33.923 ***** 
changed: [test1]

TASK [flask : debug stop_result] ***********************************************
Wednesday 23 October 2024  10:28:40 +0800 (0:05:15.389)       0:05:49.313 ***** 
ok: [test1] => {
    "stop_result.stdout_lines": "VARIABLE IS NOT DEFINED!"
}

timer 插件日志

=============================================================================== 
flask : systemctl stop flask ------------------------------------------ 315.39s
flask : systemctl status flask ----------------------------------------- 14.61s
flask : backup /data/flask/test into /data/flask-baks/test-2024-10-23.10.28.42.tar.gz -- 10.07s
flask : start flask service --------------------------------------------- 9.97s
Gathering Facts --------------------------------------------------------- 7.96s
flask : pip install requirements.txt ------------------------------------ 6.09s
flask : create /data/flask, /data/flask-baks directory ------------------ 5.20s
flask : pip install flask_cors prometheus-client ------------------------ 4.31s
flask : copy flask.service ---------------------------------------------- 3.86s
flask : copy flask logrotate config ------------------------------------- 3.83s
flask : Set SELinux to permissive mode ---------------------------------- 3.03s
flask : supervisorctl stop test -------------------------------- 2.91s
flask : systemd enable flask service ------------------------------------ 2.89s
flask : set run env ----------------------------------------------------- 2.70s
flask : check anaconda3 existence --------------------------------------- 2.67s
flask : chmod /data/flask/test/ -------------------------------- 2.65s
flask : Check if app-role file exists ----------------------------------- 2.55s
flask : set flask env --------------------------------------------------- 2.52s
flask : check miniconda3 existence -------------------------------------- 2.48s
flask : check that the requirements.txt exists -------------------------- 2.47s
Playbook run took 0 days, 0 hours, 6 minutes, 52 seconds

原文地址:https://blog.csdn.net/uwoerla/article/details/144323938

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!