Я новичок в ansible и jenkins. Я использую конвейер для извлечения кода из git и замены некоторых свойств в нем на ansible, и я получаю эту ошибку при попытке изменить свойства.
Commit message: "Update replace-property_Gbs.yml"
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (replace-property-files)
[Pipeline] sh
+ ansible-playbook cicd-gbs/replace-property_Gbs.yml -e 'db_ip=localhost db_user=root db_pass=Gbs@2018 db=sf_inventory public_ip=96.126.116.100'
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
PLAY [To replace the correct values in properties file] ************************
TASK [Gathering Facts] *********************************************************
fatal: [localhost]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"failed": true, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}}, "msg": "The following modules failed to execute: setup\n"}
PLAY RECAP *********************************************************************
это мой ANSIBLE СКРИПТ, в котором я пытаюсь заменить какое-то свойство в коде после его получения из git через конвейерный скрипт
---
- name: To replace the correct values in properties file
hosts: localhost
become: true
vars:
ip: "{{ db_ip }}"
user: "{{ db_user }}"
password: "{{ db_pass }}"
dbname: "{{ db }}"
pub_ip: "{{ public_ip }}"
tasks:
- name: to remove unwanted properties files for now
file:
path: "/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/config-server/src/main/resources/config/{{ item }}"
state: absent
with_items:
- production-service-dev.properties
- stock-management-service-dev.properties
- name: To replace the DB Ip on all properties files
replace:
path: "{{ item }}"
regexp: '^spring.datasource.url=*(.+)$'
replace: "spring.datasource.url=jdbc:mysql://{{ ip }}:3306/{{ dbname }}?autoReconnect=true&useSSL=false&nullNamePatternMatchesAll=true&serverTimezone=Asia/Jakarta"
with_items:
- '/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/config-server/src/main/resources/config/buyback-service-dev.properties'
- name: to change the port number on application-propertyfile
replace:
path: '/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/config-server/src/main/resources/application.properties'
regexp: '9090'
replace: '8821'
- name: To replace the db user name
replace:
path: "{{ item }}"
regexp: '^spring.datasource.username=*(.+)$'
replace: "spring.datasource.username={{ user }}"
with_items:
- '/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/config-server/src/main/resources/config/buyback-service-dev.properties'
- name: To replace the db password
replace:
path: "{{ item }}"
regexp: '^spring.datasource.password=*(.+)$'
replace: "spring.datasource.password={{ db_pass }}"
with_items:
- '/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/config-server/src/main/resources/config/buyback-service-dev.properties'
- name: To change the log location
replace:
path: "{{ item }}"
regexp: 'logs'
replace: '/home/app/jenkinsdeployment'
with_items:
server/src/main/resources/config/distribution-service-dev.properties
- '/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/config-server/src/main/resources/config/buyback-service-dev.properties'
- name: To change the public ip address on property IP
replace:
path: "{{ item }}"
regexp: '10.16.45.40'
replace: "{{ pub_ip }}"
with_items:
- '/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/config-server/src/main/resources/config/buyback-service-dev.properties'
- name: To change the port no in bootstrap properties on discovery-gateway service
replace:
path: "{{ item }}"
regexp: '9090'
replace: "8821"
with_items:
- '/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/discovery-gateway/src/main/resources/bootstrap.properties'
- name: To add the entry for cassendra
lineinfile:
path: "{{ item }}"
regexp: '^spring.data.cassandra.contact-points'
line: 'spring.data.cassandra.contact-points=localhost'
with_items:
- '/var/lib/jenkins/workspace/cicd-gbs/cicd-gbs/config-server/src/main/resources/config/buyback-service-dev.properties'
Может ли кто-нибудь помочь мне с этим ?