review: setup awx server with ansible
parent
6034d87f97
commit
84bceb730d
@ -1,74 +1,77 @@
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
64363634663737386334633461386262333537616332666562633062666163633664306663343432
|
||||
3864363865353062393836646165643138393533396333320a383161323865353734653033656563
|
||||
37633463373163336365666639356362306236646236643433613335623734313462303335333635
|
||||
3133616330373534350a666334303966383264663833366538376436396535666633616338336163
|
||||
30343266323031633139663338306466313230646233623863383334666332353061333235636236
|
||||
37333165336461643261356532306262623231343362613037363933356366643363333663613866
|
||||
36373963616238666161653432393565636532666665356665633339316363613336386133633766
|
||||
38363430303464386165396536633766383263646631653664376262393832323465333837363566
|
||||
65646262323430396237396235303962346264363431313235396264363834366230373036396432
|
||||
63623063393336326139623334656434303039393966663030653436373834636539646636386331
|
||||
35323839663863313733393261363361666261643463363736653663313364363565643564636536
|
||||
61396466613237313938623731623735626264373564633263303336383766306163643561376661
|
||||
32396139666433393432646463353730383461323139346461346662326535613532623034646162
|
||||
35626666653536666630386135613162343165323637646235383363663232343036383035363063
|
||||
37653966663836396531303738333564613933366531373738626132333634623261623533373966
|
||||
65663063323831393962373439326334363632326339643863613161316532313534613536363537
|
||||
35633666643265303461633564336530353136393063333935383163313766643334333234623430
|
||||
34656531643637306365353231303532323732353566316433336138656233336365616638303437
|
||||
37633366626139366666333466393436313265643935383631393362323666623131383331383464
|
||||
37303838386566396239656330636162386566366131616630316566633333333262333534336463
|
||||
64353838306238396637623763633464333966653432653732303063326235383830363237313565
|
||||
63366563323537616334396330303131363732626136313437363537656665353564373439313831
|
||||
34663834623136333961653737363163376636336264643064343635376532326132363035383637
|
||||
37336465653933663931376633346538663866363135626465653138353339646161383636663238
|
||||
33313831646163353131303234333637306337613561393361616337373537306161616562343331
|
||||
33646362366134373339376366616364633263633562613463663936663966613566346638396434
|
||||
36313638313663626538373539353437316363646166393866643062353333386533333632333164
|
||||
35643463353731306537316465373730666334626235663039316632626430313337303632616237
|
||||
37386633373634333238623464353139316236613039313961653535613835636562393335646637
|
||||
33326666653532636230343766323937313331666334333830383264653135663962356138313737
|
||||
63316431393565323166343164663530356130316335323662323530373233356435323965303866
|
||||
35376462306136333565386533366637333265393264303136663161626661666635323136316430
|
||||
66623962616365363962393838333133313133323431636530306539303837333731326566396335
|
||||
38636464353936363030303764623861373362656237303032653661613262626431353238336536
|
||||
30343865633165613433613635376337643632613562656133633435333063313262366561343535
|
||||
36363562313766666263653934376161656332626333323062346131346132323331316332646266
|
||||
35373562633639386266646439623866336434373536633236316361383233663363643936656339
|
||||
35333736663966326166613261626531616530353165326162653564363832386232313764663737
|
||||
30336666356463356161613566373661633566303061353439373162306330396437356461663139
|
||||
31646465623234343130623736653031326230323432656462366435653564623433393539626537
|
||||
36646536313033663937363535366361386535613436313735383931666533646662633831303538
|
||||
64306437306631303162336561323431373464623031333932356433363536346533366430366238
|
||||
32306166376262616165353635386164633933663732373933376430396362663465343331616636
|
||||
66306431626233343564663235376465623665373536653136633932353265666366633235363461
|
||||
62623063613730666530333030613463636363383431653130643137373737393134643064333332
|
||||
64393134323137303164623238636235623266323466373430393265323637366131333166643666
|
||||
32303338656536373539303433383964373862333032363333373333313839353763643061313930
|
||||
35333833353465643938633365366261633438316264356234363766383438366161333862383338
|
||||
32633433346462353733323761613633343734393439386333346534393564633166646166306236
|
||||
62336266373766363332303866393733353263323164646535323066306134623538663532363665
|
||||
39366539386362363538653363336639323634366631393732616563393561363333383435363730
|
||||
34626166393239656636366562333261346431366330393339356537383034663961306636356633
|
||||
31623262323434656465333536376565373736383537613361373062636631353631636433343161
|
||||
62356534326239376264303439373033626336303031313661303333636663366366343534636237
|
||||
37356438316539643663363237363131666537333562656439323739656635393665366538323462
|
||||
30346539393764316435353962363266653439376232656263326262653833313564633636303639
|
||||
61373064373164316462346234313536643537373630323339353866646436663538653234643932
|
||||
32353238613166336330633434323363363439373339383139393137376337303531346430396637
|
||||
61363638353665373364383365613538373962613830666535636339636336646436326433663065
|
||||
64643330313666373035653031326535633739616437386261386333356234343334316432313363
|
||||
34626637633362343464646565343330383239303431316333323337626531623966316438623839
|
||||
37623461303138653030356632623064656333373866633165353062613831313364653135613738
|
||||
37666331663532366437393663636237636333636564656131303331643961363737626437353934
|
||||
34633463353561313035613261323137386461313362626462626335306433383530313534626539
|
||||
30656638396232303031363937643164653230356462663435636436306166383436383231383935
|
||||
61653937353163666234333465363237386465656637313235386338626561306531363633626563
|
||||
34343431663238663633643165326664346237356337646231653639313234633332623330623734
|
||||
66656166303666656565626461626332383261353862366562626231646461323231393162323738
|
||||
33303236326362383932643533383165613766376666333338666636316636353062346136623335
|
||||
32643966353734616333336665653032363162623035346662386237623663356666303038346137
|
||||
61383334643762663865393264343533386666343435313661613133613535336466373638363165
|
||||
64623062623932323137633162623832356566393464333061646537613431616339393131333137
|
||||
36643639383639326537316434643761653762356130633165373637303938343930
|
||||
61653336363762373661306133636238666261646334366539636532303830303534396432363337
|
||||
3639643337313965333439663937303937613763326439650a663863646335643432336661326661
|
||||
66316266366538393161373334383765363965393035633562383039396631623962663666313762
|
||||
6637373237623762620a656261633562366136616562363564346630646236613463316533643663
|
||||
39633261643163373535333332356364393465363636316130663030376232303732653339343964
|
||||
31303666366264613265336337376433316435396537613937623039623733373663623739363232
|
||||
32376435613161643030363739323735346436316436343133373338363232663464363134626663
|
||||
35313734666137626335313334666433666562373461653435653862333432343462376430356332
|
||||
33373336613766666131646633303834353832383461386362336164643562656562343061383133
|
||||
30646430346232303836653032373235633166313233383839386565343266323634306531326366
|
||||
30326136613363643766613262393930653864383037656630623434376661646231376335633530
|
||||
39303438633230623063643832646164646261343938313334313762323538666530313066666530
|
||||
35616664656437383735633831623032316137373133353639666161643962663730613034346635
|
||||
39393133346334633461663061386165616562383531316636343734636331613764386339613861
|
||||
61623138616334313763356530323533366362366135383962653061353732613937303337663533
|
||||
36646435383466316461616563613837393230396232616237663635353534336237663765376433
|
||||
35353136373130323564393634313332373936396161316634333362663431643031366435383230
|
||||
37343333343636373964363834356337656266616337313035326338353930356561616431383139
|
||||
36663966386366656338343561363764313563656238326536383363646363613431626463306263
|
||||
39353430623763333935373935306365336165383432633733353536363462373633643663363363
|
||||
63613435363763353731653162353538336137303863363136613633306533326134616230383331
|
||||
63303561393564353031643639353032386362653733303766303235373365616237353734373765
|
||||
65336233343865313961363132616563626664353338666536636463313963326163613864333964
|
||||
38306333313938373238373832313131316162316132653861646337333465656433633530303565
|
||||
33646565373166353630343031613166623762653737303335316430386334363565663538316433
|
||||
37323661366262363735373134623162316630653132666565626632396664326132323439373233
|
||||
37613738643463616135626236306665313961376261356466643462396466303234356536393739
|
||||
39396338373438316165343566376466343935306237656463356537623230313663306232623562
|
||||
31333662316438393131376333323934646165373232393034613763373166333335313634393630
|
||||
32303666356338326231613033363863353536373930653132656331653334366539376436393864
|
||||
39343863656539306365383563666631376264623862346562333635653934376531356331303737
|
||||
30313665343337333762383861373835303339663335346236646361333234393435623663353437
|
||||
31396535333163373762333431306563393962303537633763363638616136323231326162386664
|
||||
35636161383361323561373236363461616464346535336535666632626435376637326239333738
|
||||
33633336643133373461616631613530623636316536633631643034326230376633616563316565
|
||||
33363962313762386432613536646334313961383739663339623362336564353339396233326133
|
||||
30366464646466636435303531616430326561643630343138633935663966383234356662376637
|
||||
39323839376163626633353963633161636432656663343962626337616665323432303735366530
|
||||
63383964636665646432646337353634313434343564613139333363303863396663303263363631
|
||||
30313366633361386636643134336566326565373861666334623563646133666261333235626537
|
||||
37323666333566343430626137313563303336376437366238663234653566653437363633366436
|
||||
37633961616337656565323739336435393533663862643632373933633733626165363630353430
|
||||
30343536613164343461333464616638313139306535313032303364653765363462646235656230
|
||||
64346436613231353334356266613562663032386564633534373332306563656365346534633137
|
||||
65346533353035383864643739646631333938613461373234323234383063373138353230323862
|
||||
30313062346663336633666231666530613134386236653362396331356330336234393365393062
|
||||
34396534393232643764623932633963306461373065643865376239393262616635303230616161
|
||||
62643161656237373531373934346461653062636136383533376436383462316538373064656433
|
||||
33306638393637316134636663633331643134333532366666316536366233333839356632393038
|
||||
38353034326563366235623865616164323530303037306432623761616131633361303237323736
|
||||
62346439623131343964323665316438656366376638333362336365393334316132393633376637
|
||||
66373037353339383232346437656239383336643436323462663933653031653439393433653265
|
||||
38393162356235313733376466633535313463346638613365333235656631343436376138333361
|
||||
65653264323861623739613262333365386530373063623332323965383938653465646261633139
|
||||
33663235373261653039636630666138363034373662373561386630386633393433386436623530
|
||||
30663863646666633865393431356633326634393364396166636639343931333564626437373066
|
||||
66383639313738613234626361323564383739396335356632313961376137363735346566653639
|
||||
62663838646133653465333139613734356336613762393032363131333961336335633237373535
|
||||
31363661636538336435306537343963323938376561643962313730336562323932346334376133
|
||||
37396662356165653861346230316335653765666136323930346531363334353035636661333339
|
||||
34343836373437666139376662643239616435396438663634653136323836386563366264313332
|
||||
37386637396663366332333931613436396337303664653437363931383164323038373036383661
|
||||
34313532333732656238643061323735393362343036633039653462626239323739643433343637
|
||||
35316331613937643931653264663230643939613136373065343334356131303665656561326437
|
||||
36323936373463356665356334363161343130393130646133393339316337333834333163663034
|
||||
63623039633266323736623364386665616630633133353138326566363830616233343464363338
|
||||
31366165303633636234623363336234376162346233623137386264656236653039373862396337
|
||||
35633034306138626464653637626664376638353837303236633134396264383731363931643432
|
||||
38623931346432333632653863643362346561653136623361643362616339326138383863386561
|
||||
66396435373137396263393132663834393631653461333235303135653962326235646336653463
|
||||
63663435313632613337633861653463626363643531356664663735326462353936336539663632
|
||||
31356638623939376137663666616664333037653236373135306333316362346361666165633764
|
||||
32313532343566363962663166356465303631353764333931323337636261373562666364643266
|
||||
64303636623633323736336262636164336164366433343633356362323866306561383966383134
|
||||
32633438343238373537373936376365616634396336633634356262393630383333323030663932
|
||||
37356437396635356636
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
awx_type_id: None
|
||||
changed_when: False
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search {{ awx_rest_api_type }} informations for {{ awx_search_name }} on awx server"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/{{ awx_rest_api_type }}/?search={{ awx_search_name | urlencode }}"
|
||||
method: GET
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
return_content: true
|
||||
validate_certs: false
|
||||
force_basic_auth: yes
|
||||
status_code: 200
|
||||
register: awx_type_info
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: Save result as variable (fact)
|
||||
set_fact:
|
||||
awx_type_info_json: "{{ awx_type_info.json }}"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Printing {{ awx_rest_api_type }} informations for {{ awx_search_name }}"
|
||||
debug:
|
||||
msg: "{{ awx_type_info_json }}"
|
||||
delegate_to: 127.0.0.1
|
||||
when:
|
||||
- debug
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search {{ awx_rest_api_type }} id for {{ awx_search_name }} on awx server"
|
||||
vars:
|
||||
query: '[? {{ awx_search_key }}==`{{ awx_search_name }}`].id'
|
||||
set_fact:
|
||||
awx_type_id: "{{ awx_type_info_json.results | json_query(query) | first | default(None) }}"
|
||||
when: (awx_type_info_json.results is defined) and (awx_type_info_json.results | length > 0)
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Printing {{ awx_rest_api_type }}['{{ awx_search_key }}'='{{ awx_search_name }}'].id"
|
||||
debug:
|
||||
msg: "{{ awx_type_id }}"
|
||||
delegate_to: 127.0.0.1
|
||||
when:
|
||||
- debug
|
||||
- awx_type_id is defined
|
||||
tags:
|
||||
- awx_config
|
||||
@ -0,0 +1,77 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
awx_job_template_id: "None"
|
||||
changed_when: False
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search job template {{ job.name }}"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: job_templates
|
||||
awx_search_key: name
|
||||
awx_search_name: "{{ job.name }}"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_job_template_id"
|
||||
set_fact:
|
||||
awx_job_template_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- (awx_type_id | default(None)) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Add job template {{ job.name }}"
|
||||
vars:
|
||||
name: "{{ job.name }}"
|
||||
description: "{{ job.description | default(name) }}"
|
||||
inventory_id: "{{ awx_localhost_inventory_id }}"
|
||||
project_id: "{{ awx_hetzner_ansible_project_id }}"
|
||||
execution_environment_id: "{{ awx_ee_hetzner_ansible_id }}"
|
||||
playbook: "{{ job.playbook_file | default(name + '.yml') }}"
|
||||
ask_variables_on_launch: true
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/job_templates/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-job-template.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 201
|
||||
register: response
|
||||
changed_when: response.status == 201
|
||||
when: awx_job_template_id == "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search job template {{ job.name }}"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: job_templates
|
||||
awx_search_key: name
|
||||
awx_search_name: "{{ job.name }}"
|
||||
when: awx_job_template_id == "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_job_template_id"
|
||||
set_fact:
|
||||
awx_job_template_id: "{{ awx_type_id }}"
|
||||
when: awx_job_template_id == "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- include_tasks: awx-config-job-template-credential.yml
|
||||
loop: "{{ job.credentials }}"
|
||||
loop_control:
|
||||
loop_var: awx_credential_id
|
||||
when: awx_job_template_id is defined
|
||||
tags:
|
||||
- awx_config
|
||||
@ -0,0 +1,583 @@
|
||||
---
|
||||
|
||||
- name: "Printing..."
|
||||
debug:
|
||||
msg: "{{ ansible_ssh_key_private }}"
|
||||
delegate_to: 127.0.0.1
|
||||
when:
|
||||
- debug
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Authenticating with awx server"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/me/"
|
||||
method: GET
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
return_content: true
|
||||
validate_certs: false
|
||||
force_basic_auth: yes
|
||||
status_code: 200
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search user <{{ awx_ansible_username }}>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: users
|
||||
awx_search_key: username
|
||||
awx_search_name: "{{ awx_ansible_username }}"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update ansible_awx_user_id"
|
||||
set_fact:
|
||||
ansible_awx_user_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- (awx_type_id | default(None)) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Add user <{{ awx_ansible_username }}>"
|
||||
vars:
|
||||
username: "{{ awx_ansible_username }}"
|
||||
password: "{{ awx_ansible_password }}"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/users/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-user.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 201
|
||||
register: response
|
||||
changed_when: response.status == 201
|
||||
when: ansible_awx_user_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search user <{{ awx_ansible_username }}>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: users
|
||||
awx_search_key: username
|
||||
awx_search_name: "{{ awx_ansible_username }}"
|
||||
when: ansible_awx_user_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update ansible_awx_user_id"
|
||||
set_fact:
|
||||
ansible_awx_user_id: "{{ awx_type_id }}"
|
||||
when: ansible_awx_user_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search credential type id for <Machine>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credential_types
|
||||
awx_search_key: name
|
||||
awx_search_name: "Machine"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_type_machine_id"
|
||||
set_fact:
|
||||
awx_credential_type_machine_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- awx_type_id | default(None) != None
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search <Machine> credentials <hetzner-ansible-ssh>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "hetzner-ansible-ssh"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_hetzner_ansible_id"
|
||||
set_fact:
|
||||
awx_credential_hetzner_ansible_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- (awx_type_id | default(None)) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Add <Machine> credentials <hetzner-ansible-ssh>"
|
||||
vars:
|
||||
name: "hetzner-ansible-ssh"
|
||||
user_id: "{{ ansible_awx_user_id }}"
|
||||
credential_type_id: "{{ awx_credential_type_machine_id }}"
|
||||
credential_type_name: "Machine"
|
||||
username: "Ansible"
|
||||
ssh_public_key_data: "{{ lookup('file', '{{ playbook_dir }}/users/ansible/id_rsa.pub') }}"
|
||||
ssh_key_data: "{{ ansible_ssh_key_private }}"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/credentials/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-credential.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 201
|
||||
register: response
|
||||
changed_when: response.status == 201
|
||||
when: awx_credential_hetzner_ansible_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search <Machine> credentials <hetzner-ansible-ssh>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "hetzner-ansible-ssh"
|
||||
when: awx_credential_hetzner_ansible_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_hetzner_ansible_id"
|
||||
set_fact:
|
||||
awx_credential_hetzner_ansible_id: "{{ awx_type_id }}"
|
||||
when: awx_credential_hetzner_ansible_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search credential type id for <Vault>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credential_types
|
||||
awx_search_key: name
|
||||
awx_search_name: "Vault"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_type_vault_id"
|
||||
set_fact:
|
||||
awx_credential_type_vault_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- awx_type_id | default(None) != None
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search <Vault> credentials <hetzner-ansible-vault>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "hetzner-ansible-vault"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_hetzner_ansible_vault_id"
|
||||
set_fact:
|
||||
awx_credential_hetzner_ansible_vault_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- (awx_type_id | default(None)) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Add <Vault> credentials <hetzner-ansible-vault>"
|
||||
vars:
|
||||
name: "hetzner-ansible-vault"
|
||||
user_id: "{{ ansible_awx_user_id }}"
|
||||
credential_type_id: "{{ awx_credential_type_vault_id }}"
|
||||
credential_type_name: "Vault"
|
||||
vault_password: "{{ vault_ansible_password }}"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/credentials/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-credential.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 201
|
||||
register: response
|
||||
changed_when: response.status == 201
|
||||
when: awx_credential_hetzner_ansible_vault_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search <Vault> credentials <hetzner-ansible-vault>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "hetzner-ansible-vault"
|
||||
when: awx_credential_hetzner_ansible_vault_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_hetzner_ansible_vault_id"
|
||||
set_fact:
|
||||
awx_credential_hetzner_ansible_vault_id: "{{ awx_type_id }}"
|
||||
when: awx_credential_hetzner_ansible_vault_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search credential type id for <Container Registry>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credential_types
|
||||
awx_search_key: name
|
||||
awx_search_name: "Container Registry"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_type_container_registry_id"
|
||||
set_fact:
|
||||
awx_credential_type_container_registry_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- (awx_type_id | default(None)) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search <Container Registry> credentials <dev-docker-registry-01.smardigo.digital>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "dev-docker-registry-01.smardigo.digital"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_docker_registry_id"
|
||||
set_fact:
|
||||
awx_credential_docker_registry_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- awx_type_id | default(None) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Add <Container Registry> credentials <dev-docker-registry-01.smardigo.digital>"
|
||||
vars:
|
||||
name: "{{ shared_service_docker_registry_hostname }}"
|
||||
description: "{{ shared_service_docker_registry_hostname }}"
|
||||
user_id: "{{ ansible_awx_user_id }}"
|
||||
credential_type_id: "{{ awx_credential_type_container_registry_id }}"
|
||||
credential_type_name: "Container Registry"
|
||||
host: "{{ shared_service_docker_registry_hostname }}"
|
||||
username: "{{ docker_registry_username }}"
|
||||
password: "{{ docker_registry_token }}"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/credentials/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-credential.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 201
|
||||
register: response
|
||||
changed_when: response.status == 201
|
||||
when: awx_credential_docker_registry_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search <Container Registry> credentials <dev-docker-registry-01.smardigo.digital>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "dev-docker-registry-01.smardigo.digital"
|
||||
when: awx_credential_docker_registry_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_credential_docker_registry_id"
|
||||
set_fact:
|
||||
awx_credential_docker_registry_id: "{{ awx_type_id }}"
|
||||
when: awx_credential_docker_registry_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search execution environment for <hetzner-ansible>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: execution_environments
|
||||
awx_search_key: name
|
||||
awx_search_name: "hetzner-ansible"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_ee_hetzner_ansible_id"
|
||||
set_fact:
|
||||
awx_ee_hetzner_ansible_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- (awx_type_id | default(None)) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Add execution environment <hetzner-ansible>"
|
||||
vars:
|
||||
name: "hetzner-ansible"
|
||||
description: "hetzner-ansible"
|
||||
image: "dev-docker-registry-01.smardigo.digital/awx/awx-custom-ee"
|
||||
credential: "{{ awx_credential_docker_registry_id }}"
|
||||
pull: "always"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/execution_environments/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-execution-environment.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 201
|
||||
register: response
|
||||
changed_when: response.status == 201
|
||||
when: awx_ee_hetzner_ansible_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search execution environment for <hetzner-ansible>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: execution_environments
|
||||
awx_search_key: name
|
||||
awx_search_name: "hetzner-ansible"
|
||||
when: awx_ee_hetzner_ansible_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_ee_hetzner_ansible_id"
|
||||
set_fact:
|
||||
awx_ee_hetzner_ansible_id: "{{ awx_type_id }}"
|
||||
when: awx_ee_hetzner_ansible_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search inventory <localhost>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: inventories
|
||||
awx_search_key: name
|
||||
awx_search_name: "localhost"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_localhost_inventory_id"
|
||||
set_fact:
|
||||
awx_localhost_inventory_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- (awx_type_id | default(None)) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Add inventory <localhost>"
|
||||
vars:
|
||||
name: "localhost"
|
||||
description: "localhost"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/inventories/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-inventory.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 201
|
||||
register: response
|
||||
changed_when: response.status == 201
|
||||
when: awx_localhost_inventory_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search inventory <localhost>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: inventories
|
||||
awx_search_key: name
|
||||
awx_search_name: "localhost"
|
||||
when: awx_localhost_inventory_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_localhost_inventory_id"
|
||||
set_fact:
|
||||
awx_localhost_inventory_id: "{{ awx_type_id }}"
|
||||
when: awx_localhost_inventory_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Create archive for repository <hetzner-ansible>"
|
||||
shell: cd {{ playbook_dir }} && git archive --format tar.gz -o /tmp/hetzner-ansible.tar.gz HEAD
|
||||
delegate_to: 127.0.0.1
|
||||
become: false
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Remove old rpository folder for <hetzner-ansible>"
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ awx_project_path }}/hetzner-ansible"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Create project folder for <hetzner-ansible>"
|
||||
file:
|
||||
path: "{{ awx_project_path }}/hetzner-ansible"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0555'
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Extract repository archive for <hetzner-ansible>"
|
||||
unarchive:
|
||||
src: /tmp/hetzner-ansible.tar.gz
|
||||
dest: "{{ awx_project_path }}/hetzner-ansible"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Remove repository archive for <hetzner-ansible>"
|
||||
file:
|
||||
state: absent
|
||||
path: /tmp/hetzner-ansible.tar.gz
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search project <hetzner-ansible>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: projects
|
||||
awx_search_key: name
|
||||
awx_search_name: "hetzner-ansible"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_hetzner_ansible_project_id"
|
||||
set_fact:
|
||||
awx_hetzner_ansible_project_id: "{{ awx_type_id }}"
|
||||
when:
|
||||
- (awx_type_id | default(None)) != "None"
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Add project <hetzner-ansible>"
|
||||
vars:
|
||||
name: "hetzner-ansible"
|
||||
description: "hetzner-ansible"
|
||||
local_path: "hetzner-ansible"
|
||||
default_environment_id: "{{ awx_ee_hetzner_ansible_id }}"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/projects/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-project.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 201
|
||||
register: response
|
||||
changed_when: response.status == 201
|
||||
when: awx_hetzner_ansible_project_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Search project <hetzner-ansible>"
|
||||
include_tasks: awx-config-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: projects
|
||||
awx_search_key: name
|
||||
awx_search_name: "hetzner-ansible"
|
||||
when: (awx_hetzner_ansible_project_id is not defined)
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Update awx_hetzner_ansible_project_id"
|
||||
set_fact:
|
||||
awx_hetzner_ansible_project_id: "{{ awx_type_id }}"
|
||||
when: awx_hetzner_ansible_project_id is not defined
|
||||
tags:
|
||||
- awx_config
|
||||
|
||||
- name: "Create job templates on awx server"
|
||||
include_tasks: awx-config-job-template.yml
|
||||
loop:
|
||||
- {
|
||||
name: "create-server",
|
||||
#description: "create-server",
|
||||
#playbook_file: "create-server.yml",
|
||||
credentials: [
|
||||
"{{ awx_credential_hetzner_ansible_vault_id }}",
|
||||
"{{ awx_credential_hetzner_ansible_id }}",
|
||||
]
|
||||
}
|
||||
- {
|
||||
name: "create-database-container",
|
||||
#description: "create-database-container",
|
||||
#playbook_file: "create-database-container.yml",
|
||||
credentials: [
|
||||
"{{ awx_credential_hetzner_ansible_vault_id }}",
|
||||
"{{ awx_credential_hetzner_ansible_id }}",
|
||||
]
|
||||
}
|
||||
- {
|
||||
name: "create-database-cluster",
|
||||
#description: "create-database-cluster",
|
||||
#playbook_file: "create-database-cluster.yml",
|
||||
credentials: [
|
||||
"{{ awx_credential_hetzner_ansible_vault_id }}",
|
||||
"{{ awx_credential_hetzner_ansible_id }}",
|
||||
]
|
||||
}
|
||||
- {
|
||||
name: "create-realm",
|
||||
#description: "create-realm",
|
||||
#playbook_file: "create-realm.yml",
|
||||
credentials: [
|
||||
"{{ awx_credential_hetzner_ansible_vault_id }}",
|
||||
"{{ awx_credential_hetzner_ansible_id }}",
|
||||
]
|
||||
}
|
||||
- {
|
||||
name: "create-service",
|
||||
#description: "create-service",
|
||||
#playbook_file: "create-service.yml",
|
||||
credentials: [
|
||||
"{{ awx_credential_hetzner_ansible_vault_id }}",
|
||||
"{{ awx_credential_hetzner_ansible_id }}",
|
||||
]
|
||||
}
|
||||
loop_control:
|
||||
loop_var: job
|
||||
tags:
|
||||
- awx_config
|
||||
@ -1,586 +0,0 @@
|
||||
---
|
||||
- name: "Add basic configuration awx server"
|
||||
block:
|
||||
- name: "Authenticating with awx server"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/me/"
|
||||
method: GET
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
return_content: true
|
||||
validate_certs: false
|
||||
force_basic_auth: yes
|
||||
status_code: 200
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Search 'Ansible' user to awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: users
|
||||
awx_search_key: username
|
||||
awx_search_name: "Ansible"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update ansible_awx_user_id"
|
||||
set_fact:
|
||||
ansible_awx_user_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Add Ansible user to awx server"
|
||||
vars:
|
||||
username: "Ansible"
|
||||
password: "Ansible"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/users/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-user-config.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 200, 201
|
||||
when: (ansible_awx_user_id is not defined) and (ansible_awx_user_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Search 'Ansible' user on awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: users
|
||||
awx_search_key: username
|
||||
awx_search_name: "Ansible"
|
||||
awx_type_id: ""
|
||||
when: (ansible_awx_user_id is not defined)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update ansible_awx_user_id"
|
||||
set_fact:
|
||||
ansible_awx_user_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: >
|
||||
(ansible_awx_user_id is not defined) and
|
||||
(awx_type_id is defined) and
|
||||
(awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get 'Machine' type id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credential_types
|
||||
awx_search_key: name
|
||||
awx_search_name: "Machine"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_type_machine_id"
|
||||
set_fact:
|
||||
awx_credential_type_machine_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get 'Machine' type 'Hetzner-Ansible' type id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "Hetzner-Ansible"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_hetzner_ansible_id"
|
||||
set_fact:
|
||||
awx_credential_hetzner_ansible_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Add 'Machine' type 'Hetzner_Ansible' credential to awx server"
|
||||
vars:
|
||||
name: "Hetzner-Ansible"
|
||||
user_id: "{{ ansible_awx_user_id }}"
|
||||
credential_type_id: "{{ awx_credential_type_machine_id }}"
|
||||
credential_type_name: "Machine"
|
||||
username: "Ansible"
|
||||
ssh_public_key_data: "{{ lookup('file', '{{ playbook_dir }}/users/ansible/id_rsa.pub') | replace('\n', '') }}"
|
||||
ssh_key_data: "{{ lookup('file', '{{ playbook_dir }}/users/ansible_ssh_key') | replace('\n', '') }}"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/credentials/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-credential-config.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 200, 201
|
||||
tags:
|
||||
- awx_communication
|
||||
when: >
|
||||
(awx_credential_hetzner_ansible_id is not defined) and
|
||||
(ansible_awx_user_id is defined) and
|
||||
(ansible_awx_user_id | length > 0) and
|
||||
(awx_credential_type_machine_id is defined) and
|
||||
(awx_credential_type_machine_id | length > 0)
|
||||
|
||||
- name: "Get 'Machine' type 'Hetzner_Ansible' type id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "Hetzner-Ansible"
|
||||
awx_type_id: ""
|
||||
when: (awx_credential_hetzner_ansible_id is not defined)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_hetzner_ansible_id"
|
||||
set_fact:
|
||||
awx_credential_hetzner_ansible_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: >
|
||||
(awx_credential_hetzner_ansible_id is not defined) and
|
||||
(awx_type_id is defined) and
|
||||
(awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get 'Vault' type id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credential_types
|
||||
awx_search_key: name
|
||||
awx_search_name: "Vault"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_type_vault_id"
|
||||
set_fact:
|
||||
awx_credential_type_vault_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get 'Vault' type 'Hetzner_Ansible_Vault' type id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "Hetzner-Ansible-Vault"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_hetzner_ansible_vault_id"
|
||||
set_fact:
|
||||
awx_credential_hetzner_ansible_vault_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Add 'Vault' type 'Hetzner-Ansible-Vault' credential to awx server"
|
||||
vars:
|
||||
name: "Hetzner-Ansible-Vault"
|
||||
user_id: "{{ ansible_awx_user_id }}"
|
||||
credential_type_id: "{{ awx_credential_type_vault_id }}"
|
||||
credential_type_name: "Vault"
|
||||
#should be more secure
|
||||
vault_password: devops123
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/credentials/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-credential-config.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 200, 201
|
||||
tags:
|
||||
- awx_communication
|
||||
when: >
|
||||
(awx_credential_hetzner_ansible_vault_id is not defined) and
|
||||
(ansible_awx_user_id is defined) and
|
||||
(ansible_awx_user_id | length > 0) and
|
||||
(awx_credential_type_vault_id is defined) and
|
||||
(awx_credential_type_vault_id | length > 0)
|
||||
|
||||
- name: "Get 'Vault' type 'Hetzner-Ansible-Vault' type id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "Hetzner-Ansible-Vault"
|
||||
awx_type_id: ""
|
||||
when: (awx_credential_hetzner_ansible_vault_id is not defined)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_hetzner_ansible_vault_id"
|
||||
set_fact:
|
||||
awx_credential_hetzner_ansible_vault_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: >
|
||||
(awx_credential_hetzner_ansible_vault_id is not defined) and
|
||||
(awx_type_id is defined) and
|
||||
(awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Search 'Container Registry' type id to awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credential_types
|
||||
awx_search_key: name
|
||||
awx_search_name: "Container Registry"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_type_container_registry_id"
|
||||
set_fact:
|
||||
awx_credential_type_container_registry_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get 'Docker Registry' id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "Docker Registry"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_docker_registry_id"
|
||||
set_fact:
|
||||
awx_credential_docker_registry_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Add 'Container Registry' credential to awx server"
|
||||
vars:
|
||||
name: "Docker Registry"
|
||||
description: "Docker Registry Smardigo Credentials"
|
||||
user_id: "{{ ansible_awx_user_id }}"
|
||||
credential_type_id: "{{ awx_credential_type_container_registry_id }}"
|
||||
credential_type_name: "Container Registry"
|
||||
host: "dev-docker-registry-01.smardigo.digital"
|
||||
username: "{{ docker_registry_username }}"
|
||||
password: "{{ docker_registry_token }}"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/credentials/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-create-credential-config.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 200, 201
|
||||
tags:
|
||||
- awx_communication
|
||||
when: >
|
||||
(awx_credential_docker_registry_id is not defined) and
|
||||
(ansible_awx_user_id is defined) and
|
||||
(ansible_awx_user_id | length > 0) and
|
||||
(awx_credential_type_container_registry_id is defined) and
|
||||
(awx_credential_type_container_registry_id | length > 0)
|
||||
|
||||
- name: "Get 'Docker Registry' id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: credentials
|
||||
awx_search_key: name
|
||||
awx_search_name: "Docker Registry"
|
||||
awx_type_id: ""
|
||||
when: (awx_credential_docker_registry_id is not defined)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_credential_docker_registry_id"
|
||||
set_fact:
|
||||
awx_credential_docker_registry_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: >
|
||||
(awx_credential_docker_registry_id is not defined) and
|
||||
(awx_type_id is defined) and
|
||||
(awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get 'Hetzner-Ansible' execution environment id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: execution_environments
|
||||
awx_search_key: name
|
||||
awx_search_name: "Hetzner-Ansible"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_ee_hetzner_ansible_id"
|
||||
set_fact:
|
||||
awx_ee_hetzner_ansible_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Register execution environment container image to awx server"
|
||||
vars:
|
||||
name: "Hetzner-Ansible"
|
||||
description: "test"
|
||||
image: "dev-docker-registry-01.smardigo.digital/awx/awx-custom-ee"
|
||||
credential: "{{ awx_credential_docker_registry_id }}"
|
||||
pull: "always"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/execution_environments/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-add-ee-config.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 200, 201
|
||||
tags:
|
||||
- awx_communication
|
||||
when: >
|
||||
(awx_ee_hetzner_ansible_id is not defined) and
|
||||
(awx_credential_docker_registry_id is defined) and
|
||||
(awx_credential_docker_registry_id | length > 0)
|
||||
|
||||
- name: "Get 'Hetzner-Ansible' execution environment id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: execution_environments
|
||||
awx_search_key: name
|
||||
awx_search_name: "Hetzner-Ansible"
|
||||
awx_type_id: ""
|
||||
when: (awx_ee_hetzner_ansible_id is not defined)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_ee_hetzner_ansible_id"
|
||||
set_fact:
|
||||
awx_ee_hetzner_ansible_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: >
|
||||
(awx_ee_hetzner_ansible_id is not defined) and
|
||||
(awx_type_id is defined) and
|
||||
(awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get 'localhost' inventory id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: inventories
|
||||
awx_search_key: name
|
||||
awx_search_name: "localhost"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_localhost_inventory_id"
|
||||
set_fact:
|
||||
awx_localhost_inventory_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Add a empty 'localhost' inventory to awx server"
|
||||
vars:
|
||||
name: "localhost"
|
||||
description: "localhost"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/inventories/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-add-inventory-config.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 200, 201
|
||||
tags:
|
||||
- awx_communication
|
||||
when: (awx_localhost_inventory_id is not defined)
|
||||
|
||||
- name: "Get 'localhost' inventory id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: inventories
|
||||
awx_search_key: name
|
||||
awx_search_name: "localhost"
|
||||
awx_type_id: ""
|
||||
when: (awx_localhost_inventory_id is not defined)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_localhost_inventory_id"
|
||||
set_fact:
|
||||
awx_localhost_inventory_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: >
|
||||
(awx_localhost_inventory_id is not defined) and
|
||||
(awx_type_id is defined) and
|
||||
(awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Tar hetzner-ansible repository"
|
||||
shell: cd {{ playbook_dir }} && git archive --format tar.gz -o /tmp/hetzner-ansible.tar.gz HEAD
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Remove old archive awx project folder"
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ awx_project_path }}/hetzner-ansible"
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Create Project Folder 'hetzner-ansible'"
|
||||
file:
|
||||
path: "{{ awx_project_path }}/hetzner-ansible"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0555'
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Extract hetzner-ansible repository to the awx project folder"
|
||||
unarchive:
|
||||
src: /tmp/hetzner-ansible.tar.gz
|
||||
dest: "{{ awx_project_path }}/hetzner-ansible"
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Cleanup created hetzner-ansible archive"
|
||||
file:
|
||||
state: absent
|
||||
path: /tmp/hetzner-ansible.tar.gz
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get 'Hetzner-Ansible' projects id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: projects
|
||||
awx_search_key: name
|
||||
awx_search_name: "Hetzner-Ansible"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_hetzner_ansible_project_id"
|
||||
set_fact:
|
||||
awx_hetzner_ansible_project_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Add 'Hetzner-Ansible' project to awx server"
|
||||
vars:
|
||||
name: "Hetzner-Ansible"
|
||||
description: "Hetzner-Ansible"
|
||||
local_path: "hetzner-ansible"
|
||||
default_environment_id: "{{ awx_ee_hetzner_ansible_id }}"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/projects/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-add-project-config.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 200, 201
|
||||
tags:
|
||||
- awx_communication
|
||||
when: >
|
||||
(awx_hetzner_ansible_project_id is not defined) and
|
||||
(awx_ee_hetzner_ansible_id is defined)
|
||||
|
||||
- name: "Get 'hetzner-ansible' projects id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: projects
|
||||
awx_search_key: name
|
||||
awx_search_name: "Hetzner-Ansible"
|
||||
awx_type_id: ""
|
||||
when: (awx_hetzner_ansible_project_id is not defined)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_hetzner_ansible_project_id"
|
||||
set_fact:
|
||||
awx_hetzner_ansible_project_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: >
|
||||
(awx_hetzner_ansible_project_id is not defined) and
|
||||
(awx_type_id is defined) and
|
||||
(awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Create job templates on awx server"
|
||||
include_tasks: awx-create-job-template.yml
|
||||
loop:
|
||||
- { name: "create-database", desc: "create-database", playbook_file: "create-database.yml", credentials: ["{{ awx_credential_hetzner_ansible_vault_id }}", "{{ awx_credential_hetzner_ansible_id }}"] }
|
||||
- { name: "create-realm", desc: "create-realm", playbook_file: "create-realm.yml", credentials: ["{{ awx_credential_hetzner_ansible_vault_id }}", "{{ awx_credential_hetzner_ansible_id }}"] }
|
||||
- { name: "create-server", desc: "create-server", playbook_file: "create-server.yml", credentials: ["{{ awx_credential_hetzner_ansible_vault_id }}", "{{ awx_credential_hetzner_ansible_id }}"] }
|
||||
- { name: "create-service", desc: "create-service", playbook_file: "create-service.yml", credentials: ["{{ awx_credential_hetzner_ansible_vault_id }}", "{{ awx_credential_hetzner_ansible_id }}"] }
|
||||
loop_control:
|
||||
loop_var: jobinfo
|
||||
tags:
|
||||
- awx_communication
|
||||
@ -1,83 +0,0 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
awx_job_template_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get {{jobinfo.name}} job_templates id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: job_templates
|
||||
awx_search_key: name
|
||||
awx_search_name: "{{jobinfo.name}}"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_create_database_job_template_id"
|
||||
set_fact:
|
||||
awx_job_template_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: (awx_type_id is defined) and (awx_type_id | length > 0)
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Add {{jobinfo.name}} job_template to awx server"
|
||||
vars:
|
||||
name: "{{jobinfo.name}}"
|
||||
description: "{{jobinfo.desc}}"
|
||||
inventory_id: "{{ awx_localhost_inventory_id }}"
|
||||
project_id: "{{ awx_hetzner_ansible_project_id }}"
|
||||
execution_environment_id: "{{ awx_ee_hetzner_ansible_id }}"
|
||||
playbook: "{{jobinfo.playbook_file}}"
|
||||
ask_variables_on_launch: true
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/job_templates/"
|
||||
method: POST
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
body_format: "json"
|
||||
body: "{{ lookup('template','awx-add-job-template-config.json.j2') }}"
|
||||
force_basic_auth: true
|
||||
validate_certs: false
|
||||
status_code: 200, 201
|
||||
tags:
|
||||
- awx_communication
|
||||
when: >
|
||||
(awx_job_template_id | default("") | length == 0) and
|
||||
(awx_localhost_inventory_id is defined) and
|
||||
(awx_hetzner_ansible_project_id is defined) and
|
||||
(awx_ee_hetzner_ansible_id is defined)
|
||||
|
||||
- name: "Get {{jobinfo.name}} job_templates id from awx server"
|
||||
include_tasks: awx-get-typ-id.yml
|
||||
vars:
|
||||
awx_rest_api_type: job_templates
|
||||
awx_search_key: name
|
||||
awx_search_name: "{{jobinfo.name}}"
|
||||
awx_type_id: ""
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Update awx_job_template_id for {{jobinfo.name}}"
|
||||
set_fact:
|
||||
awx_job_template_id: "{{ awx_type_id }}"
|
||||
awx_type_id: ""
|
||||
when: >
|
||||
(awx_type_id is defined) and
|
||||
(awx_type_id | length > 0)
|
||||
# no_log: true
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- include_tasks: awx-add-credential-to-job-template.yml
|
||||
loop: "{{ jobinfo.credentials }}"
|
||||
loop_control:
|
||||
loop_var: awx_credential_id
|
||||
when: (jobinfo is defined) and (jobinfo.credentials is defined )
|
||||
tags:
|
||||
- awx_communication
|
||||
@ -1,28 +0,0 @@
|
||||
---
|
||||
|
||||
- name: "Search {{ awx_rest_api_type }} informations for {{ awx_search_name }} on awx server"
|
||||
uri:
|
||||
url: "{{ awx_base_url }}/api/v2/{{ awx_rest_api_type }}/?search={{ awx_search_name | urlencode }}"
|
||||
method: GET
|
||||
user: "{{ awx_rest_api_access_user }}"
|
||||
password: "{{ awx_rest_api_access_pw }}"
|
||||
return_content: true
|
||||
validate_certs: false
|
||||
force_basic_auth: yes
|
||||
status_code: 200
|
||||
no_log: true
|
||||
register: awx_type_info
|
||||
tags:
|
||||
- awx_communication
|
||||
|
||||
- name: "Get {{ awx_rest_api_type }} id for {{ awx_search_name }} on awx server"
|
||||
vars:
|
||||
query: '[? {{ awx_search_key }}==`{{ awx_search_name }}`].id'
|
||||
set_fact:
|
||||
awx_type_id: "{{ item.results | json_query(query) | first }}"
|
||||
when: (item.results is defined) and (item.results | length > 0)
|
||||
loop:
|
||||
- "{{ awx_type_info['content'] }}"
|
||||
no_log: true
|
||||
tags:
|
||||
- awx_communication
|
||||
@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "{{ name }}",
|
||||
"description": "{{ description | default("") }}",
|
||||
{% if organization_id is defined %}
|
||||
"organization": "{{ organization_id }}",
|
||||
{% endif %}
|
||||
"image": "{{ image }}",
|
||||
"credential": "{{ credential }}",
|
||||
"pull": "{{ pull }}" {# "": "---------", "always": "Always pull container before running.",
|
||||
"missing": "Only pull the image if not present before running.",
|
||||
"never": "Never pull container before running." #}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "{{ name }}",
|
||||
"description": "{{ description | default("") }}",
|
||||
{% if organization_id is defined %}
|
||||
"organization": "{{ organization_id }}",
|
||||
{% endif %}
|
||||
"image": "{{ image }}",
|
||||
"credential": "{{ credential }}",
|
||||
"pull": "{{ pull }}"
|
||||
}
|
||||
Binary file not shown.
@ -1,31 +0,0 @@
|
||||
{
|
||||
"name" : "Accounts",
|
||||
"restApi" : true,
|
||||
"configKey" : "accounts",
|
||||
"payloadType" : "EXCEL",
|
||||
"config" : [ {
|
||||
"name" : "file",
|
||||
"type" : "FILE",
|
||||
"value" : "master_data.xlsx"
|
||||
}, {
|
||||
"name" : "columnNames",
|
||||
"type" : "STRING",
|
||||
"value" : ""
|
||||
}, {
|
||||
"name" : "sqlStatement",
|
||||
"type" : "STRING",
|
||||
"value" : "select * from accounts"
|
||||
}, {
|
||||
"name" : "columnNameLineNumber",
|
||||
"type" : "INT",
|
||||
"value" : 1
|
||||
}, {
|
||||
"name" : "skipEmptyLines",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : false
|
||||
}, {
|
||||
"name" : "skipEmptyColumns",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : false
|
||||
} ]
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name" : "awx-job-templates-plain",
|
||||
"restApi" : true,
|
||||
"configKey" : "awx-job-templates-plain",
|
||||
"payloadType" : "REST",
|
||||
"config" : [ {
|
||||
"name" : "connection",
|
||||
"type" : "CONNECTION",
|
||||
"value" : "awx"
|
||||
}, {
|
||||
"name" : "resource",
|
||||
"type" : "STRING",
|
||||
"value" : "api/v2/job_templates?search=${name}"
|
||||
}, {
|
||||
"name" : "sqlStatement",
|
||||
"type" : "STRING",
|
||||
"value" : "SELECT results FROM default_table"
|
||||
} ]
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name" : "awx-job-templates",
|
||||
"restApi" : true,
|
||||
"configKey" : "awx-job-templates",
|
||||
"payloadType" : "POST_PROCESSING",
|
||||
"config" : [ {
|
||||
"name" : "datasource_key",
|
||||
"type" : "STRING",
|
||||
"value" : "awx-job-templates-plain"
|
||||
}, {
|
||||
"name" : "groovy_script",
|
||||
"type" : "STRING",
|
||||
"value" : "def result = []\ndata.each{templates ->\n templates.results.each{ template ->\n if (parameters['name'] == template.name) {\n result.add([id: template.id, name: template.name])\n }\n }\n}\nresult"
|
||||
} ]
|
||||
}
|
||||
Loading…
Reference in New Issue