ansible deploy docker

main
gwen 5 months ago
parent 3a71e5e75b
commit c3c3907b5b

@ -0,0 +1,16 @@
# deploy_machine:
# hosts:
# # Déploiement sur Perso VPS
# home_vps:
# ansible_connection: ssh
# ansible_host: "{{ lookup('env', 'VPS_IP') }}"
# ansible_user: "{{ lookup('env', 'VPS_USER') }}"
# ansible_ssh_private_key_file: "{{ lookup('env', 'VPS_SSH_KEY') }}"
all:
hosts:
multipass_vm:
ansible_host: 10.13.166.245
ansible_user: ubuntu
ansible_ssh_private_key_file: key/tmp_deploy
ansible_python_interpreter: /usr/bin/python3

@ -0,0 +1,174 @@
$ANSIBLE_VAULT;1.1;AES256
30353666306461663632323630376537623465313130303233383932636565303536613264326565
3930346636366564353035306132643063383339333733330a343464376237643833356132343532
30376365333266666362326437663038373238333962643637613535613163353761306636383131
6664333964373632300a336139303964663131613133383034306464333530393836386566333930
65633661353836653235376539663034363561303465303065393263376564393363633565636664
63613564323332326232646537616135656565653331626534666434346566653530386333383438
65623731313938396463323232396333656430353938613862396561613435633038663237653461
62303433366662636263623030303731303531386230316364613431356332646232396635653731
65356363343433313739343032623866393438616433663237326430376466656661383330363931
64393839393066346664383230393361646135373135383565353665313538306334336433386538
30356164646430376161636436663561633636343139643466373638663930343936333936313065
33653939653964386137633263333439663863653761393661323561353935316634343931303966
62363536626533653365393631383965313033653161336131313739666436363962643063323934
37393932613461666535633733663861643435383935333061363034366563343130316462356537
64383433393239376433323932313736633930353031616235623734663863393932656261386235
34383862303334363138333563356464326432366330646166636564633035323830353334623562
62353733353137323837333263383834373834663132626434386166363562383431623832393233
32663430653065303161336331626132646565366537626234666565373138313438336361313635
61313537353033333332336533323563316231376137353762613632363432353938313538613363
34333732393539666238373830353066383538393135333739373065356339353335386438623831
61386564393863623832396664666430633535326165303932323231353837373065633565393836
37396164616535386632343463363738316538366564393163306132383463366263653262653662
62373461373034623063353930623633653636323634663532346634363966646662383436326561
31333333363362653766303164373038393630666263396434633434376230613362343937336536
64383961373432653237303731333836306265346632323965386535363463616532633261613736
37353839323661396163653038643162313833393638393562356365393839623634613037643433
66366336303534666433626635306336356339666331343565623164653732666562316631613038
64626334303534303061386437303233306530653032663238653463303130313133346338323335
62363161383631316535333339303663303865376331383436623166313464653332383963636538
34363131373433663436613132616635373166383632333262306462333263333839356563336536
36373739646637366430653036333363333035303063623232653735656261323231656364623934
38663532353339613733633262303139306435323132313730343739386364376562336436353161
34313331646235316365666532333666343435633064636632643031336666313834636537623930
65383138373233343134643166393532373363376433666132636430363362343531623530376666
33333062383735626533346438613762373538383137623835643635316261393364373732343232
37636430373539393366373332383164363334356331663539366365616362643338356463623338
66386633666537613539616238356238643839376661633430393738353833656238643366616363
66333161663264626564386437656665386663616437343461366235396364356631326365333030
34373435393863326232373961623937376462623264653931316265626538383462316434396532
64373835663938646162346436306563666362626361353964643239386136643762393536306130
33316434343432343933376239313238313634303435613030396434633931313264366465363063
64643733663837313034366538623466656235663239363661383836336363393238343731343465
35353730393130323161653732656561323838306435376439326464396637643331646132623838
36363363373235313830326436306237343339353931363031663866376264393437323166623866
38326461666433613834663863653566653862383762333165353337653365623633393636393966
37363132306638326265323337363939363362613162343561303866353131363937666261336265
37613530643631633065323939396236626562656366636333656538656134356538373966316139
30333764376133616165623862616136326338316133373562353235643632356239323463346666
62306635333762396534303635303336363036336639303731326565383934643136616231363038
33376436383066356534386130336262343732303737653761386261396431383131393630316630
66653764306361356563336239373031623739313064373038633939356634346263363531613733
61656634343036323633613263643262663034376132653338353230663166653134623930653236
32313462623335376364346539396538646132633231396138316537306465383634353362613363
36656634333038643837653536346365626634316361666135646637333331613134306461363861
65366635646334306331353338383364336464343437663230646239363139343963303034323434
66646565396162633762386662366334376165363265323338656431623838323930643465623139
32366661306662663834383561623961363463393863343565393931303136333932343964333736
61316430646332333034616332636334653262666232383139333363346634663064393863343131
63383365396163303662333664646164313966366137323761356237356464323963343365643935
62643366653631363836633130653632646466393636353166323433653936383437333961366435
33626232373238343936373462326363313232623633373031383834383531613938363731616161
39393330373236383631363163643630663236303334306362303636386232616239643432623866
65306463643130383661643231343838613264366235303362396464356663363538396538323364
37666136346162363338623233616666626535303134306462343831326331326432663332653239
65346662323965303638626631396266336565303332353665333564653864643832616435393265
32616464346266323439613737376362356332333031303733353866333335656633326233363331
66653764306632663834383231393838303533376437343934313539616461396537333861663035
32623638353132383362653561376335333632633363643734633633613839613638633737353336
35393538643336353763313965623931656433316166626231303233343161623838653332313639
61326138333961343439363631653931623464646336346363636636316564373931613633376633
61323436323735336664663834646637656265323732663565323733663534366639623238623464
63316535383661376536376465353738623037343931393465333265306639663032353365396165
34353866396630643661386639323430666339303332336133336438313832646236313936343634
63653364626637323135336135613666666134656462623739323861393839656330356561626334
33633337323961626437643637626134383638616637346665353963393434316237623663316130
66653632663862613334346336366138613330386232333639653436343865333938363135366130
34663830393434386331376633383836306132343562303362636533663433373039343062633635
38326261653063366435613733366534333364313063623066373934333334383335343662616339
31633837343262356131386231386538383262663734396663303532303937393766663733386334
66653664323538613361323262346437326564306634366438366438353638393963643962323730
65643262336632333466393931623035616432336466643265393633613131663336356235613562
30643536393039653962663030656462646231303830346564303839373635623534643831393964
64623436326664616539666230366465366530363362356437316165383131653037623961666235
66616463363933656139356262633232633832336132653733363436393537656137616135386265
32356264666632363233373836323236376632646161653735663134336630616461343762303334
61393362363334633532343734663232383830346534613135643134383039303635326566616632
66303238333233363738653934366636373731346363343632346563653735393033663161386663
32666132333632376136326533333964653331356262633462656630353331303733356438376563
38663736646634346637626139346530343030346137373030316136313963333863616334386531
39373937323632303736646235653430346436633930326536323037653031633238353335313135
38346463653734303334653639636530376664626164663632333265373531666162653966633430
32353265353137643962386531333532316531653634363463646530363861643239323035383533
34666364393761626237653235363332376334393664616462646166366664303330613561633839
30356336326363383064663034613833393730323932356434623131346230663539653961366436
34653564633530656235326564333039336161373537623830643932663035303737363331303265
39633137303937346566616634393330656362376366663437636365316334343839653362646265
36333934623630356463303866393030663037353465306466653230353164333765653233616664
35376436616635323032663336333134353764626430653136366264343361306438323531336436
34656266313566393430623763343230643839616434336264626332333635333933313864366161
62343761323663356463343231366164313065373863613036363433343438346561643931396432
37646234323031306336656262653363333335306535613833653232383637376632616563343932
64386135623565333964663237333038663766393930633863386566613637383939636635373937
32363232636335313866366433366264613932623832376136353264666131393130653039373935
66396432333233386538623034376138356239386566326633356338613165616133653032666133
64646333363564373531626338323737633332383666633438383562623764396464653561323662
39366266643836363536376261623833323734616630386632303633666632323131636634613030
39656561373631613036653263663937393361303036396536613632303030383730316364636331
61363438366363623961333161666263393639343363633538643266393963363064383266663432
61376132633261303634663539366136303637333233386536356130313033313666303064353963
63346336613339343533373537376165643233626339306666366238653732303538343562323762
64623261333166316366383935613965333034303832313435323065333963316133343037626432
31393534373062663130373831333839626539626166346632363761313065623932663738333662
61353437373761313131313861346331613937326530626535663937646337353565666465356530
34376162663738323035626637343566313932343038666466316334326231666364333163366333
36383632323134313564336337326530663337616262643166393238613332653730363438646166
30343636323936616661653239656235383061663961383833373239623461323939643764386261
62386634376463363866643862333437653566666262663933663565366132353132613261336631
65613364616133653231353262656634646665366361363461356336313565346138366366333632
66643836623864353265346538663362393561613838643736626363343734663361386436366330
61363132353336626132313565653935343666313835623631363833646230303465353931353061
32326530326164343031386361313139336333316666373234613066336464363661663466646138
38643830346665346261623563383065346433336338613361373430306363616264653762626462
34613862306330623731353537663565636137656663656661303035623434343436333265306462
36656164636462303937666232636664636332633431306161653435393630313462636335326437
37316334313737643464326230633333303934613534653661343532646563333630623363343863
36366139643939653763383464323630336435373931373766613261346664666165623037396265
38646633383037356234643234376338353664666163363736663761373063343637363166633938
39373364386463646232626130376435663631313464376161376566626332373933333033396132
32363434353436616564626539333535336530623764343534336138613665313762356566383861
65393737613130326564343561616435326135356666653535336538386134363664313835313163
63363964636331386463303331646264633231353662393230613932663764383761333533616665
31656261353932613331643366316537336231613432653936643365376130356438376332303738
66626631313437303064366536626436393132633430336165326266643232613538363839376133
30353334356232333762343237376137366365343632303237646332626330383663386166376431
35616233366364366233326537653438313230383736326234363138313861393334383138653831
39306665383538666237626365613966646531613966656235383161613466366337613030376261
61613031396661633932656562353733303464343239313233623339323236323332343838343531
30616165366138383933633837663765666263376539373436393966323363316365666361366661
34366361656635636566623930393335633762313863386537313064343561663437393432333038
33633338663230356638623962633833616335386361653431333966646130616436653264663261
33633434306536303964646332663863396564353865626263306132623463336364393433323939
31323730386137366339303339333839613430303631636265616632313061396461326161366235
39653338616165383665386439336134613235353162316161633661363430336439333232316466
39323364363361356133613736383338326162343164633835336139326533346534376437343835
33393464626137653532616632396432373466616630633833333935633732666362623462373434
38653430316438306138663062303836353261313265316332316533393666386138636164656165
61336364303762346334646134656665636235626436623430333733336537663033323533326635
39393162373965323566353234623538323030373964613163363262663031303935303033666437
33353861323037316437326139353164303764383538663237366264663333666134643964643033
32663538366134366630303534373963393561653036346364623261373738326366616639353836
64316265316462616461656665613331373636343865373935363035323639656437666234393738
65393231363733626665623437343631383230346433326266663035316564646436636639316232
37646336613431343438306338306463393435663039343737643062396661353435663136383061
61366130343131613264393533396538336435643737646465373461316634343864643561313530
34373733363834373564333037333266303465313963613335393862313030336265306232346138
34633064626364636165393437363431376130326261653137333264623932353466313236316135
34666637623864376531383937323833323131386461396663656533393236373232343134396263
62356262613132336263343163313362313837313833333133306364653332313332383837383462
65353463353162663935626533356162373463383065326232636634333530303638663165343533
64383266633834323462643634646562653761326164373161343339363238626337303263643336
61633034646362323330323939663539393661313832633633326165323864633134353430643237
64616639356435356533353262303066386662333162376566386564396161313865333064636565
31313934326134346663656166623966666439633262623039643034316261356639613638313765
37373562353331353139386335633161333136316634373963663932346266363865343563393338
38316431353435633130316465636336353536396637656339393737336232346338623462343336
37323963316237383464306232666332663031626363323061333732326338326264633166616563
64346165336165313865393864666435363538613865616465333533666363396137366338356235
37316638323432616665656530613563373966663961383635613634396533393261376162313633
32343366393437356130646161393638363734336637323338396437643935383831393765383037
32383032636137316139373665366134636266643732333364623066353639373165356135373339
37663032383038373762343334326662646565303361306131623337303062316566343032653835
30613631616631313665616561633634373734376536376438373765616237303536336564393561
3232

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCNDMlDx9dR/jzx/mBEmIrA6K7+OI7AKJ0vBqESMJ59+QqdxHbHlGtdDKX8+QTvtouasH6FgLtBvZgRuwu+bOuHOTYLevz3To/PP63mq7q5BV2VSjRaHfU9Z84q1Pd+/RpCHP14H2iyTgRnGBfn5Z8uUBuptd+P/HP1PCvxQvCA6BtZPzgmQ9xoDWkOyiqbKbaK1ai3bI8sKoRjTbYGa7nbUcFob4oofFgQAvi4qZSLTG93CdQBlVftAlsPPtSNOoZu/JQcuPlZHBUVTLPcfUtyt7meOrgoToNsWV82vdbU03ALJipkoJueSKhUZJa0XS/alE0MeKoVUtXB4zUIg8iM1OB4qAUsIUjXCc469C0LKsPxYyyw7N3/TI6I+Yxfdnpd7AVECHG9QXIv9p03TG+1QlRvOK/JIouIh/y/IJXX1L0sAT75SKThZoOAES/u0B3X8IVZMCIZ0eG0taJbbQ0uDnFlkoLtSzdVSJAR3fohnB+Axr1On2SIacEqK9JRP0M/doTuLMyp3ospWxO1VRj8jFSJH4yOhxsTMgcs2stSu/JZdpJeIzBc11cilThjOLVNOKLJWG4YjPWSkbQ7FSSzdV53tNd3DD3W156yTUv09z/1tsAA9SHhtP2L71cnmgSJiffOz+W5LcTa75WklkN7Nv0djvXcvmDJj0oXT7+Drw== matt@dell

@ -0,0 +1,49 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAgEAjQzJQ8fXUf488f5gRJiKwOiu/jiOwCidLwahEjCeffkKncR2x5Rr
XQyl/PkE77aLmrB+hYC7Qb2YEbsLvmzrhzk2C3r8906Pzz+t5qu6uQVdlUo0Wh31PWfOKt
T3fv0aQhz9eB9osk4EZxgX5+WfLlAbqbXfj/xz9Twr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+8PB6VC4mYI
Nx6nbnsVIaLldC1Zg2u1DJu5nhvUp08BPW7cefEry/G9NNIuo65mQtxJPefpbwiqfhnzSh
4FVio1ph9LOK3XtsT/Py7Nm4B6LvyQndPPSMBOP+dj9BZ6fGidU+smTkliRdzg+RBFDCPM
f5AimaE89q0KzGwAAAEBAMR9RLgg2F/fqhInnMKtC7cDxWZdQTq3WrQYSUHePRExjzR/IQ
ymtCWuZKkZ22KFboYyDtsTao6vn8cG1C6oyHD6ZLravob2U1hxC+4q3IvTRSe0DU3dSi/Y
bztKFOBvQqfu6wJ6r9ctHchV709tCyRgByY76d41cwVlGzbUKGLrEMK6CJHrZf9kP51Yus
vjbx19fssnSbOhNhpZ4vyb30NzxnuJAi+8EfWNF4JAIw5qqhrCR9JGVu1gSC5/CnrHNDdZ
bTVbfk39Zg8hA8npREbKL0hG9WM5Ap6dsc4H0PviNl2hUfVkAkPH96jx78yKA1hvv4RylH
G5J/YxlM9RZuEAAAEBALfFC2QunxbAtwuVAq9somYb/RhwGVJ+xw47XlxCMMc9NCC3Oc5I
mJJQFdeCCbPsXZaH/P2Q1v7+e0s8TR3ZaLoL6OYQ5HZzYEoKFRVNbU3ISDmaIKd5+Cu8vg
hYhAHIX104WjObh2N+RdEl8BacKwbMIYwQmX9NJ9vgU+0Kx9VQomWg0e9Elz3u+aPpEeCW
zLoP2DtFWWRi4/qgrBGTqmiPFg0dSsHI5KjYM0TInGor6Zlwc34O5mZ81vG68aOppfq4fQ
t6P8HQi/Gq28HyMCRSVdrbeL7xi3YeK00Z15VHBPyREMpl7EN7scbR+YA4IG05sP08luTj
3o0G6RGEjI8AAAAJbWF0dEBkZWxsAQI=
-----END OPENSSH PRIVATE KEY-----

@ -0,0 +1,15 @@
- name: Deploy docker image on VPS
hosts: multipass_vm
remote_user: ubuntu
gather_facts: false
become: true
become_method: sudo
vars:
ssh_private_key_file: key/deploy
roles:
- decrypt
- docker
- docker-compose
# - remove

@ -0,0 +1,8 @@
- name: Decrypt SSH private key
copy:
src: "{{ ssh_private_key_file }}"
dest: key/tmp_deploy
decrypt: yes
mode: '0600'
delegate_to: localhost
become: false

@ -0,0 +1,34 @@
- name: Download the latest Docker Compose binary
get_url:
url: https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-linux-x86_64
dest: /tmp/
mode: '0755'
- name: Download the SHA256 checksum file
get_url:
url: https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-linux-x86_64.sha256
dest: /tmp/
- name: Verify the SHA256 checksum
command: sha256sum -c /tmp/docker-compose-linux-x86_64.sha256
args:
chdir: /tmp
register: sha256_check
failed_when: sha256_check.rc != 0
- name: Move the new Docker Compose binary to /usr/bin
command: mv /tmp/docker-compose-linux-x86_64 /usr/bin/docker-compose
when: sha256_check.rc == 0
- name: Apply executable permissions to the binary
file:
path: /usr/bin/docker-compose
mode: '0755'
- name: Verify Docker Compose installation
command: docker-compose --version
register: docker_compose_version
- name: Display Docker Compose version
debug:
msg: "Docker Compose version: {{ docker_compose_version.stdout }}"

@ -0,0 +1,44 @@
---
- name: Install docker install
ansible.builtin.include_tasks: install.yml
- name: Create Docker Compose directory
file:
path: /opt/deploy
state: directory
mode: '0755'
- name: Synchorisation du folder
synchronize:
src: ../../../../
dest: /opt/deploy
- name: Create directory for MongoDB keys
file:
path: /opt/deploy/catalogue/mongoDb/keys
state: directory
mode: '0755'
- name: Generate MongoDB replica set key
command: openssl rand -base64 756
register: mongo_key
- name: Write MongoDB replica set key to file
copy:
content: "{{ mongo_key.stdout }}"
dest: /opt/deploy/catalogue/mongoDb/keys/mongo-replica-set.key
mode: '0600'
owner: '999'
group: '999'
- name: Log in to the private Docker registry
community.docker.docker_login:
registry: "{{ docker_registry }}"
username: "{{ docker_username }}"
password: "{{ docker_password }}"
reauthorize: yes
- name: Start Docker Compose services
ansible.builtin.shell:
cmd: docker-compose up -d
chdir: /opt/deploy

@ -0,0 +1,3 @@
docker_registry: xxx
docker_username: xxx
docker_password: xxx

@ -0,0 +1,17 @@
---
- name: Install Snapd
apt:
name: snapd
state: present
update_cache: yes
- name: Install Docker via Snap
community.general.snap:
name: docker
state: present
- name: Ensure Docker service is running
service:
name: snap.docker.dockerd
state: started
enabled: yes

@ -0,0 +1,4 @@
- name: Remove file (delete file)
ansible.builtin.file:
path: /tmp/id_rsa
state: absent

@ -0,0 +1,19 @@
Concourse
-------------
- install concourse avec docker-compose
- install de fly
tunel ssh pour pouvoir accéder à l'appli web
ssh -L 8080:localhost:8080 ubuntu@mistergwen.site
fly -t tutorial login -c http://localhost:8080 -u test -p test
fly -t tutorial set-pipeline -p hello-world -c hello-world.yml
fly -t tutorial unpause-pipeline -p hello-world
fly -t tutorial trigger-job --job hello-world/hello-world-job --watch
pour nettoyer :
fly -t tutorial destroy-pipeline -p hello-world

@ -0,0 +1,40 @@
Dans le contexte d'un pipeline **Concourse**, une **target** fait généralement référence à un **environnement de déploiement** ou à un **ensemble d'objectifs (targets)** où un job doit être exécuté. Cela fait partie de la configuration permettant de déterminer où les ressources et les jobs doivent être déployés ou exécutés, que ce soit sur un environnement local ou distant.
### Définition et utilisation de "target" dans un pipeline Concourse :
1. **Environnement d'exécution** :
- Une target représente l'endroit où les actions de pipeline (telles que les jobs ou les ressources) seront exécutées. Ce peut être un serveur de déploiement, un environnement de tests, ou une machine virtuelle dans le cas de Concourse. Chaque instance de Concourse peut être configurée pour interagir avec des environnements différents ou des ressources externes à travers des "targets".
2. **Dans les ressources et les actions** :
- Dans un pipeline Concourse, des ressources (comme les dépôts Git, les images Docker, ou les artefacts) peuvent être connectées à des targets, ce qui indique à Concourse de quelle manière et où interagir avec ces ressources.
- Exemple : si vous avez une ressource qui interagit avec un service externe comme AWS, une cible peut être utilisée pour configurer l'authentification et l'interaction avec cet environnement.
3. **Dans la configuration de Concourse** :
- Concourse utilise des "targets" dans sa configuration pour déterminer les paramètres relatifs aux connexions aux systèmes externes. Les **targets** sont utilisés dans des fichiers de configuration ou de pipeline pour établir des connexions aux environnements de déploiement ou aux systèmes tiers. Par exemple, cela pourrait concerner des environnements comme `production`, `staging` ou `dev`.
### Exemple pratique :
Disons que vous avez un pipeline qui déploie une application sur plusieurs environnements, par exemple :
- Un environnement de développement (dev).
- Un environnement de staging.
- Un environnement de production.
Chaque environnement aurait une **target** associée. Par exemple :
```yaml
resources:
- name: git-repo
type: git
source:
uri: "https://github.com/monrepo"
branch: master
target: staging # Ici la target désignerait l'environnement "staging" pour ce job
jobs:
- name: deploy-dev
plan:
- get: git-repo
trigger: true
- task: deploy-to-dev
target: dev # Ici la target désignerait l'environnement "dev"
```
### Conclusion :
En résumé, une **target** dans un pipeline **Concourse** est un mécanisme pour spécifier où les ressources doivent être utilisées ou où les actions doivent être exécutées. C'est une abstraction pour interagir avec différents environnements ou systèmes externes en fonction du contexte de votre pipeline. Cela permet d'avoir un contrôle fin sur le déploiement, l'exécution des tâches, et l'intégration avec d'autres outils ou plateformes.

@ -0,0 +1,25 @@
resources:
- name: exo_resource
type: git
source:
uri: https://forge.gwenaelremond.fr/gwen/larochellemaalsi2023/
branch: develop
jobs:
- name: job-resource
plan:
- get: exo_resource
trigger: true
- task: diff
config:
inputs:
- name: exo_resource
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
run:
path: echo
args: ["Test"]

@ -0,0 +1,35 @@
version: '3'
services:
concourse-db:
image: postgres
environment:
POSTGRES_DB: concourse
POSTGRES_PASSWORD: concourse_pass
POSTGRES_USER: concourse_user
PGDATA: /database
concourse:
image: concourse/concourse
command: quickstart
privileged: true
depends_on: [concourse-db]
ports: ["8080:8080"]
environment:
CONCOURSE_POSTGRES_HOST: concourse-db
CONCOURSE_POSTGRES_USER: concourse_user
CONCOURSE_POSTGRES_PASSWORD: concourse_pass
CONCOURSE_POSTGRES_DATABASE: concourse
CONCOURSE_EXTERNAL_URL: http://localhost:8080
CONCOURSE_ADD_LOCAL_USER: test:test
CONCOURSE_MAIN_TEAM_LOCAL_USER: test
# instead of relying on the default "detect"
CONCOURSE_WORKER_BAGGAGECLAIM_DRIVER: overlay
CONCOURSE_CLIENT_SECRET: Y29uY291cnNlLXdlYgo=
CONCOURSE_TSA_CLIENT_SECRET: Y29uY291cnNlLXdvcmtlcgo=
CONCOURSE_X_FRAME_OPTIONS: allow
CONCOURSE_CONTENT_SECURITY_POLICY: "*"
CONCOURSE_CLUSTER_NAME: tutorial
CONCOURSE_WORKER_CONTAINERD_DNS_SERVER: "8.8.8.8"
# For ARM-based machine, change the Concourse runtime to "houdini"
CONCOURSE_WORKER_RUNTIME: "containerd"

@ -0,0 +1,15 @@
jobs:
- name: hello-world-job
plan:
- task: hello-world-task
config:
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
outputs:
- name: the-artifact
run:
path: ls
args: ["-lF"]

@ -0,0 +1,36 @@
jobs:
- name: hello-world-job
plan:
- task: hello-world-task
config:
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
outputs:
- name: the-artifact
run:
path: sh
args:
- -cx
- |
ls -l .
echo "hello from another step!" > the-artifact/message
- task: read-the-artifact
config:
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
# To receive "the-artifact", specify it as an input
inputs:
- name: the-artifact
run:
path: sh
args:
- -cx
- |
ls -l .
cat the-artifact/message

@ -0,0 +1,26 @@
---
resources:
- name: exo_resource
type: git
source:
uri: https://forge.gwenaelremond.fr/gwen/chateauroux/
branch: develop
jobs:
- name: job-resource
plan:
- get: exo_resource
trigger: true
- task: diff
config:
inputs:
- name: exo_resource
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
run:
path: echo
args: ["Test"]

@ -0,0 +1,10 @@
- task: hello
config:
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
run:
path: echo
args: ["Hello world!"]

@ -0,0 +1,16 @@
resources:
- name: ci
type: git
source:
uri: https://forge.gwenaelremond.fr/gwen/chateauroux
branch: main
version:
ref: 8e78227300e4dcd88d7b85a84a15f4a0fc5ece8f
jobs:
- name: time-job
public: true
plan:
- get: ci
- task: hello
file: hello.yml

@ -0,0 +1,13 @@
jobs:
- name: hello-world-job
plan:
- task: hello-world-task
config:
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
run:
path: echo
args: ["Hello world!"]

@ -0,0 +1,25 @@
jobs:
- name: hello-world-job
plan:
- task: hello-world-task
config:
# Tells Concourse which type of worker this task should run on
platform: linux
# This is one way of telling Concourse which container image to use for a
# task. We'll explain this more when talking about resources
image_resource:
type: registry-image
source:
repository: busybox # images are pulled from docker hub by default
# The command Concourse will run inside the container
# echo "Hello world!"
# run:
# path: echo
# args: ["Hello world!"]
outputs:
- name: the-artifact
run:
# Change the command to `ls -lF` to see
# what the task sees in its working directory
path: ls
args: ["-lF"]

@ -0,0 +1,39 @@
jobs:
- name: hello-world-job
plan:
- task: hello-world-task
config:
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
outputs:
- name: the-artifact
run:
# This is a neat way of embedding a script into a task
path: sh
args:
- -cx
- |
ls -l .
echo "hello from another step!" > the-artifact/message
# Add a second task that reads the contents of the-artifact/message
- task: read-the-artifact
config:
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
# To receive "the-artifact", specify it as an input
inputs:
- name: the-artifact
run:
path: sh
args:
- -cx
- |
ls -l .
cat the-artifact/message
cp -a the-artifact /tmp/

@ -0,0 +1,15 @@
---
resources:
- name: resource-tutorial
type: git
source:
uri: https://github.com/starkandwayne/concourse-tutorial.git
branch: develop
jobs:
- name: job-hello-world
public: true
plan:
- get: resource-tutorial
- task: hello-world
file: resource-tutorial/tutorials/basic/task-hello-world/task_hello_world.yml

@ -0,0 +1,14 @@
#to be lauched with the -i arg
#fly -t tutorial execute -c manual_launch.yml -i manual=.
platform: linux
image_resource:
type: registry-image
source:
repository: alpine/ansible
inputs:
- name: manual
run:
args:
- manual/print_hello.yml
path: ansible-playbook
Loading…
Cancel
Save