new.afpy.org

This commit is contained in:
Julien Palard 2020-12-17 22:02:23 +01:00
parent 9cc7befb78
commit 36bac2368f
2 changed files with 197 additions and 34 deletions

View File

@ -1,35 +1,38 @@
$ANSIBLE_VAULT;1.1;AES256
64376361613965323865623433666232633330643434326562393064393039356166373639646361
3361346238626566383963383837643139326530343665640a376336356366316439333739366139
34376135366661626664663532616662353736643064386235346236346433656533313937353462
3935393434653533340a613664373432653734353462326532316539616162303539663463636331
38626263303033666236336439636134363136643836343266656362313331316432316130383130
66656563393232353436376262623861323761393836386162363630623331396530393737366531
36383163663732313633643731363763353035333931326639623863373039333131393762616631
61356436383763353037353030663663343265366339613866623161653834376133326564383937
32633464643330343334323831653235333338303433366535303662386264383438373230336432
33363364373237326131303561363530353533646466656432633739373137306363396162336639
35303562623962343532633939653332333931333434363164383264373232353230633933643635
66633533376664303639363035383066366537373462343834363230623535393366353163646537
62346535313663336438363535356165316635306438643938333434633136323962623638363462
31386633646562633838613366616665393934376436623535643535343962363137303665363963
39353238373438666462313862653534313935333562653434386131323539313037336235303834
32383865613535363365326663663331633463346663353637386538376338666666386332613830
33343936353836313132333561393965393531303233346666346266386532356363626539383739
35366534636331346438616630333833323037343733346133383038363637343239346332353734
31386433613465316232636562666138636539346237663331333330393336646562386433633462
36636338623865663136656134613463663963333063316336366366626438393163303838633534
31356666663031323233666331386438396130313466623432396239336463373630633262336636
65633662306535613662616338393730346132383937363038363263356436336266323161383361
34653431303431303532323331346464313639366139633434306236356565613762613264353034
61356466313562633863346135326637363064303564376562376561306665303239613930376333
34663761353561383835636132656630376436643462363764353334656261633138366134666333
31323462636263326139623461626331666137343565366336306565396637653862626565373633
64303066363930306539633566636130363563623535303631386462393235396362633262623536
36393935613665663139626562653863666334656363386636613166613663363630376438653434
35373935353865356633336533333264626337656264303564316337323138303833626433613834
65366133636235303236303835356236656165303634386132626262343663656562343036306337
31356666343736646332396537313563306362306337663966343537313063303965613938616635
35633437666331303533333863616439333139363065666133363735316239363337656364633638
35373239636134326632373138376236356539346164636436313933303237393832333435363061
6263613262353137386562626335373166393035626239333764
32306461363336613631333936656565313762653761313635666666356536393030336665303432
3232373831626133373832393930653534386662646665340a323763386533383761636462356366
65646231386361353537663038333162643063623234363765363133656363303337613432343238
3433323061656266350a643339313962316264636665363366636636343866333961346264643939
62643534346135323136636666313432353765323432653030363237346237653931646635633436
34353162376466663862333432333235316131386233666331336539643135643564373732303139
61333033333561343334313036363561303662653165303766356239333234346461386635633639
37353938326433373838633635363336353965393264323633353562373065366465346564393532
33623865636638633430353237653966386336383636363231353762353264313366636234643430
39313132613763313635383663376132663237323535656161333531633434353563363632653666
32346664353431393663313861303064613437383532626132353939373535393437643034666362
61396434393234643966666237613132333061663732323265323930313433623530303433366532
66396662646161633237623634393934323337313661666331633837383565663331316437653461
37663261666332373861656332386636653836323236346331356663383836623736326433646436
34326461613034643835306161373566616263663532636235366633626266323433386533383632
66393635633162316165303238623333383637383663346232343539666463626133313236386630
32356137333366653337333230386266323433613832323438633964383136363436303665333237
63386462316639393033623261336437626166326637396565636464623961646234326666333336
66623363656534383332363734376362616134653237653365656636363536663239653866323661
66326237343765626466353532343036363737353331303433303931626430666162623534383865
65316663393465643765613835316636633430313234663539333061343965613161333233306561
39343563663334623762306464653865363830656438653238363032393562363465633534623834
32323232353764636563613662346636623832646163303038333562313765353936303237386530
34636139333037393865356333333361633030396339336630653438613938393663646439323235
64633538313263643062666434623230396137653562396464326638643164653331643334396466
31323062663433343861383363303139346461653363343334313035353366613737663335396462
37643838356333303636383433363032653766343964616235363231393232313435313234323635
35663063346236336136623761383730303130646231313261646537366136313538376136623562
39326539663763386131396433343665383532393032633334303664643566656533643763316464
33636137336563316138313737636336616266383563653036653530313462666165333463363130
39633265343063373634366237366433386231336531383632386633646438356439343035343232
38653335313731363134323366626664343136643437613133393164646264323166326238306631
33356137623966393861366361656638623432663534343062383239383965323232636637663935
32666535383666356463636636383064353930323162643138363961636232333162333466633139
30636632386264343663346436633136316237663566653239373862663335616130366165366633
39623463373735613239316631356165326439626661316235663537333863376135393365346235
35623337373333326334306631306134616432333834313438363838643639333764

160
new.afpy.org.yml Normal file
View File

@ -0,0 +1,160 @@
---
- hosts: webservers
vars:
nginx_public_deploy_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINbgxOufHY7SxQrJNTlHmye+xeNHBA1O5SGtGhGeOVZM"
tasks:
- name: Basic setup
include_role: name=common
- name: Configure french locale
locale_gen: name="{{ item }}" state=present
with_items:
- en_US.UTF-8
- fr_FR.UTF-8
- name: Install requirements
apt:
state: present
name: [nginx, sudo]
- name: Setup new.afpy.org
include_role: name=julienpalard.nginx
vars:
nginx_owner: new-afpy-org
nginx_domain: new.afpy.org
nginx_certificates: [new.afpy.org]
nginx_conf: |
server
{
listen 80;
server_name new.afpy.org;
access_log /var/log/nginx/new.afpy.org-access.log;
error_log /var/log/nginx/new.afpy.org-error.log;
return 301 https://new.afpy.org$request_uri;
}
server
{
listen 443 ssl;
server_name new.afpy.org;
access_log /var/log/nginx/new.afpy.org-access.log;
error_log /var/log/nginx/new.afpy.org-error.log;
root /var/www/new.afpy.org/;
include snippets/letsencrypt-new.afpy.org.conf;
index index.html;
location /
{
include proxy_params;
proxy_pass http://unix:/run/new-afpy-org/website.sock;
}
location /robots.txt
{
alias /home/new-afpy-org/robots.txt;
}
location /static/
{
alias /home/new-afpy-org/src/afpy/static/;
}
location ~ ^/doc/python/(.*)$ {return 301 https://docs.python.org/fr/$1;}
location = /logo.png { return 301 https://www.new.afpy.org/static/images/logo.svg; }
location = /offres-demploi/RSS { return 301 https://www.new.afpy.org/feed/emplois/rss.xml; }
location = "/news/aggregator" { return 301 https://www.new.afpy.org/posts/actualites/1345367761; }
location = "/news/pyconfr-2012" { return 301 https://www.new.afpy.org/posts/actualites/1345377295; }
location = "/news/le-nouveau-site-de-lafpy" { return 301 https://www.new.afpy.org/posts/actualites/1364754937; }
location = "/news/un-hackathon-a-paris" { return 301 https://www.new.afpy.org/posts/actualites/1373474773; }
location = "/news/julython-contribuez-a-des-projets-opensource" { return 301 https://www.new.afpy.org/posts/actualites/1373475142; }
location = "/news/lappel-a-contribution-pour-pyconfr13-est-ouvert" { return 301 https://www.new.afpy.org/posts/actualites/1374511126; }
location = "/news/naissance-dune-communaute-saltstack-francophone" { return 301 https://www.new.afpy.org/posts/actualites/1392304489; }
location = "/news/pycon-fr-2014" { return 301 https://www.new.afpy.org/posts/actualites/1392311614; }
location = "/news/pyconfr15-ou-nous-emmeneras-tu-cette-annee" { return 301 https://www.new.afpy.org/posts/actualites/1423208987; }
location = "/news/pycon-fr-2015-we-want-you" { return 301 https://www.new.afpy.org/posts/actualites/1433966273; }
location = "/news/pycon-fr-2015-lappel-a-conferencier-est-prolonge" { return 301 https://www.new.afpy.org/posts/actualites/1438067732; }
location = "/news/pv-de-lassemblee-generale-ordinaire-2017" { return 301 https://www.new.afpy.org/posts/actualites/1506345679; }
location = "/news/code-en-seine" { return 301 https://www.new.afpy.org/posts/actualites/1507801636; }
location = "/news/rencontre-python-a-lyon" { return 301 https://www.new.afpy.org/posts/actualites/1508335902; }
location = "/news/cours-en-ligne-python-3-des-fondamentaux-aux-concepts-avances-du-langage" { return 301 https://www.new.afpy.org/posts/actualites/1509982321; }
location = "/news/atelier-de-contribution-a-ansible-a-paris" { return 301 https://www.new.afpy.org/posts/actualites/1509982513; }
location = "/news/rencontre-python-a-lyon-une-carte-pour-les-amener-tous-et-dans-la-connaissance-les-lier" { return 301 https://www.new.afpy.org/posts/actualites/1510650668; }
location = "/news/hackaton-la-boite-incubateur-imt-atlantique-rennes" { return 301 https://www.new.afpy.org/posts/actualites/1511358816; }
location = "/news/ou-sont-mes-variables" { return 301 https://www.new.afpy.org/posts/actualites/1512378516; }
location = "/news/a-vos-framewoks" { return 301 https://www.new.afpy.org/posts/actualites/1512996562; }
location = "/news/atelier-contribuez-a-la-traduction-de-la-doc-de-python-en-francais" { return 301 https://www.new.afpy.org/posts/actualites/1515405342; }
location = "/news/soiree-python-a-marseille-le-9-2-2018" { return 301 https://www.new.afpy.org/posts/actualites/1518042512; }
location = "/news/meetup-python-amiens-1" { return 301 https://www.new.afpy.org/posts/actualites/1523519011; }
}
- name: afpy user can reload own website
lineinfile:
path: /etc/sudoers
state: present
regexp: '^new-afpy-org '
line: "new-afpy-org ALL = NOPASSWD: /bin/systemctl restart new-afpy-org.service"
validate: /usr/sbin/visudo -cf %s
- name: Initial clone
become: true
become_user: new-afpy-org
git:
repo: https://github.com/Seluj78/site/
version: backend_redo
dest: /home/new-afpy-org/src/
update: no
- name: pip install AFPy website
become: true
become_user: new-afpy-org
pip:
requirements: /home/new-afpy-org/src/requirements.txt
virtualenv_command: /usr/bin/python3 -m venv
virtualenv: "/home/new-afpy-org/venv/"
- name: pip install gunicorn
become: true
become_user: new-afpy-org
pip:
name: gunicorn
virtualenv_command: /usr/bin/python3 -m venv
virtualenv: "/home/new-afpy-org/venv/"
- name: Create image directory
file:
path: /home/new-afpy-org/src/images/
mode: 0755
owner: new-afpy-org
state: directory
- name: systemd new.afpy.org service
copy:
dest: /etc/systemd/system/new-afpy-org.service
content: |
[Unit]
Description=AFPy website
After=network.target
[Service]
PIDFile=/run/new-afpy-org/website.pid
User=new-afpy-org
Group=new-afpy-org
RuntimeDirectory=new-afpy-org
WorkingDirectory=/home/new-afpy-org/src/
Environment="SENTRY_DSN={{ afpy_org_sentry_dsn }}" "FLASK_PORT=false" "FLASK_DEBUG=false" "FLASK_HOST=new.afpy.org" "FLASK_SECRET_KEY={{ vault_new_afpy_org_flask_secret_key }}" "DB_NAME=afpy.db"
Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
ExecStart=/home/new-afpy-org/venv/bin/gunicorn -w 4 \
--pid /run/new-afpy-org/website.pid \
--bind unix:/run/new-afpy-org/website.sock run
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- service: name=new-afpy-org state=started enabled=yes
handlers:
- name: reload nginx
service: name=nginx state=reloaded