Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

pipeline如何传参到ansible playbook 或者roles

我在跑脚本的时候发现pipeline的参数传不到ansible playbook里面,望求大神解决。
pipeline代码大概是这样的:
pipeline {

agent any

parameters {
    choice(name: 'ABC', choices: 'one
two
three', description: 'test parms')
}
stages {
    stage('Build') {
        steps {
            echo 'Building start...'
            echo "${params.ACTION}"
        }
    }
    }
    stage('ansible tower'){
        steps {
          ansibleTower credential: '',
          extraVars: "ABC: ${params.ABC}",
          importTowerLogs: true, 
          importWorkflowChildLogs: false, 
          inventory: '', 
          jobTags: '', 
          jobTemplate: '10001', 
          jobType: 'run', 
          limit: '', 
          removeColor: false, 
          skipJobTags: '', 
          templateType: 'job', 
          throwExceptionWhenFail: false, 
          towerServer: 'Ansible', 
          verbose: false
        }
    }
}

}

ansible playbook代码是这样的:

  • hosts: localhost
    gather_facts: false
    become: true
    become_user: test
    become_method: sudo

    tasks:

    • name: echo global var
      debug:

      msg: "{{ ABC }} "
      register: parms_result
      
    • name: echo result
      debug:

      var: parms_result.stdout_lines  

问题:
如何通过pipeline定义的参数ABC让ansible roles读取到ABC的变量


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...