From aa8735e0ea3b756b62d35cacb7ea7f8d142b3425 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Wed, 17 Aug 2016 12:55:14 +0300 Subject: [PATCH] roles/nginx: Use explicity booleans for tests instead of "yes" and "no" Better to be explict with booleans rather than being confused when you mix up yes and "yes" with Ansible/Python testing of conditionals. --- host_vars/web08 | 162 ++++++++++++++-------------- roles/nginx/tasks/vhosts.yml | 4 +- roles/nginx/templates/https.j2 | 6 +- roles/nginx/templates/vhost.conf.j2 | 10 +- 4 files changed, 91 insertions(+), 91 deletions(-) diff --git a/host_vars/web08 b/host_vars/web08 index 6e94ce1..02f67ef 100644 --- a/host_vars/web08 +++ b/host_vars/web08 @@ -1,82 +1,82 @@ $ANSIBLE_VAULT;1.1;AES256 -35616532366364373238666565313865393261346337643266643066633137353232656261343765 -3237306561623263326534323631313232363433633862650a336130613139373332366463383163 -36313865643034326162323235633232636336623430343862316336326263346532626438303330 -3264386666313237660a623661356262636530393363333264653634343336323465656334636162 -30343163666138323035386364366136626262653734326262653632393530613264663934316365 -66353731636564386431613134383862393063333537396532346663313233356361366264316362 -33663165663839663662303837303263316236633866393262346134363961333835353332646632 -66333538326365353032373533613434653065356263383537316630616632333063356366323633 -34623462356237653832383831633532306530343061353235646639633963653834316665333133 -33383764633463366235303031663732343431616332653830353365323865363837653563626437 -37373537363035643936633936393463346263626232323034646537356438663034346662343231 -39383331643432373333636530303130356331343563373932613865323235366137656637376463 -64373731653231343836336566396236323463326431656363373632383031616163643562333665 -61643334636439303764393863343533663330353233646661366232623430313764373766643634 -34613434316237383337396363396264653930663266386266363436616230663632663965363565 -31666163303438393165333938383264623630323865306465666636656430326538376661643337 -33353039636130616461663932373737343735366236326634643631346537613834643032653439 -65333337326637626637383435353130393332316366343833663634323665616164636533336335 -30316437356562663238393065656231633933373964373062326364306431303965613636316664 -34626261633334316631636366306633356430383830663631386531373734313237663237313564 -66313265653532363235643134643631303635333465643433613866393633376661383030393864 -38643563623135346631643734326132353437303030666537386639623333623361656633373034 -34306435306465373634623730613034666464663039393333356630653533666230616139656664 -32623263323066373239343564643862356336613437396264343731666631663339363738613235 -62313366383439346166303236616637336130346266336665633536303338323861326634336562 -36313963306432303239373765626534333131396533336364653338333062376631313932346664 -36333062356335313039393332316162356634656133306236323361653262313933376332623932 -65336239643838663835376534633465333166333866616539316234616565643738666537353637 -31323939383336366538353463386662383732643664353031663734363539363263306162616330 -66346636643764633461653536326264616333333539363431333263633639356361306566653565 -63363338653834343639373462386534333230633566376637323235393831333464616363346538 -66633337623463316439313039616364373238346437396461346564653063373331313433376434 -30353938323038303264616661663037326666323265656261356538623965646236303839316661 -30666334343561396361333866366333666462626130636366356439373365363536323962623462 -32343830666261383832333631306535306438386365623434623138623566623566646135386665 -39336662323933666232323263303865303530336536393363613238353465396434616335393664 -39613238316539623839396364353037653763623937666662646163666631613637353438306430 -31363165303965366362313136323031313730393262663339616133386634333336356331323130 -34663030313966353364303035663966343032313462663530363263323937623461343132616537 -35353236333038393034653764666233653862663737313437366161646539323839393230383562 -63353232663563306330306264336438356531313464363366666433343161393164656164643137 -66326363353238376437336661613732383034383131373936323436356339363833373539636130 -39656231643632623766613637653137356135346630373739353663626331663934646265626339 -63383934376263303235353662313563386662366236636232613730613038653732306139386364 -65376562323933323062396166663562623031393262636130356561336163643963343061636338 -62366666373537333231343432363664346535326361336336306461303666373032303465633062 -36663436303862633638663339646330366635343663353834656334326664656430376439623831 -34616366653234623765303963636335633664626566313164613661386531393636356432373834 -32643565356331343231363034303138643430323261323939333338326232656132613431363936 -32633561626134623035623962373536336539613137333765623232363261326466353064303465 -37373337323433393565316130623962626433333465396131643463613130656565626662363063 -31333866666165353636633338616436316237303438346537383432623662663834363265663330 -30316136313265383834623661393235633236363634383465393664633937376232616135306133 -66656533656335646265633761396237663064346262666130373064663637346331613136383064 -66323936353931643735353961303133313861396333366135303331336264646535303861356264 -39623061366332663632613137343730616231383032373266376439626634373764663461633365 -61393865656165383030313430613962393439633065663734386635643762303635366438346132 -33653838613738393564356331656132633036376434303031363563323838643130383137636565 -33323931366365383138333334613337333163396461393964353739363361363762393461663135 -30623765653939373530646130363932333934313833376537323836356262326263623663623238 -31653930313938663730306239353831396130633061396531303365616138383237316662313331 -38346561656633316364383966343438313137326363653034336331623830643263326439663965 -33613863373834343936643062613361663837366137303532653366316561363338616462646132 -65623239336234326365646564653537323539356233613937306431363133666661313038636238 -66613438336565646432373539366636373931633662353436636365633365383533366637353230 -37663336323833353065323937656134663863323739306532356264633433633731353532353536 -66386433613262656538663435646363346562326461633363363663363562616535336332613466 -35626530616265386132636538353530663132353165636164373939383235343330643237303939 -66623436613532386333333262356538613433653363643239653063656662383330623966353161 -35373861653830613137323333356630303132346532333431303466323761663038646439376661 -63393430343330313938343061636534316238386437663632343063393262646630616236643262 -64666165336564663163383062613065323935656263353236386335343338313630336438623262 -35663838663833316162653363333064623336393531333335353430303234356231373334363631 -65306466313535363433343564643864336131303464653634306564366165323930383338363863 -62653636333866396466343632653661326336336237646531373865333834386637663761633838 -33633234373464363937366135326165616630396263383261646539343466666630393563636532 -35396336393936636331613434643839383931356465636231633630636336343863323838363063 -31633031336634353337363837653861353838623438313336616665643362346633373738626465 -35366235346166633839303530376135323937313462326335616539306432303035323439366635 -66333839323163303832643334633934303938313666623830633863383063633464623538363939 -30636562353931363938613632663437663366613262373539656162336334613062 +62373634666262323432633731376338323336633239663937346231613939626135656631636430 +3561653436636132663863643032613437653664366537660a316333613366346161623032633238 +39623437393261363964646566383531383137383962363039616136383430653833626139633862 +6163363166316632380a616639343038323632396230303861396132343831393232646330373439 +35636637636335316239363931306631623834656236386633643232643630653132343863613437 +39613466393231346637373264376233613134396532653438393933616562343836353633386463 +34646537376434353834656430363363633931353838316133396531313135663232393666653762 +36353437393639303037663433323961626539643036356439396562643433616566346630303531 +30643838396131343562373634623865326564613333393362383934663738316131313566336338 +36656334306464343535623962333466663336346663313339303361633935343432643564316363 +31653662376464646165626565326133643361633638643332353436346366616530393964356361 +64303266343239663865346432393334383337343465343831353930303165356162636637343537 +62616634653132373638636630646231613130613630646133386561323363306364363966633261 +31323063356638363266623939636666333934323362646366336164386331343836663964356139 +64623936626436613766303339656365663261653338346131636437303733383736313739656432 +34333638633961653533303964623735323237646639643130333961323531383638626137373734 +65653762356464303863343861616531393132333665356662623765356632343630393962393234 +37386161306238343966393065643066303464323532393664636563366336663739333064366462 +37656461663834383033646235363635656236386639383433626237376434323764666165313730 +37376163306633326265326534653233323631633635366563353435343935376233626137653530 +38666136663866303933653739623030653064353035376665393733386132366161333861383336 +62633965653966623330303964643531333863326362313265373236313230333534343437356136 +38653166376235633562373366356262333230323634333664656639646265333265613631623365 +30643662623933376366393236636662643464393562323966313636393438336134326531616530 +37623665383136363930393766663730326337643163643939353861656663656536333662326631 +64393661363933383732306361643537643334613536343864633135623132636263353434373636 +62616662306639643938653165363130623236353731643331393962373734373661313432346161 +33323733616461383530373432666663393964646463353936363335303564653331376538396338 +62653430656537393237346131313639343535663738343631666434643038326538666332393665 +39633032633434316238656233656131343238623139376161353939326537663733386135633135 +38353762623761616664626664316436646538373133386138303430616464616366306231666663 +37643536633532343439333063303935616136626539303265633437373931396431653538343034 +31393338396130633231616231393736383830653939303536336362373534613134383239343433 +30303735373535613730646633353163626663663934623862343363633733663863373366323061 +36613738363161313565656436633939623636386535356230333731353665623834616466303862 +34333066393438306435373238373262363934333838326566646132326163656136633563363332 +33623132323663643662613864373461323733313337646263343436636564653832386263326565 +39636534393032303366613730366239353134383561356232363464613338643463316133306639 +33333639633063656366613831636131626662313165303964633165336234336435313864653438 +66393835636538303962623436633034343336303630666362646165316266323662323431663464 +65363362363132666363306333373031643037386335613263643636613939323866383362643231 +61396231303232316531643031653037313633336262353733366333356433653934336664326339 +62646330653034623532383439306235663038363066343939306533306262626537376535323530 +61343739366134323632373334353630643934653063383032313537323235326366373665613639 +36393535363635353062366465666630653831373631303161626638643332386534363835613337 +63626438303637653763653466643365366233653033653630316162393537666339643730613066 +35383061313531303531366564396237363537653434306133303464323431333037666261623432 +64336530653932626462656130323232356261323235313664383631646335383866326331653761 +35663563376162316361663330306566326465326364333362366231343463643863613434326265 +64303137313035313830613161626234623135663765636631656337326164303066393135353431 +33633965306664316230373939633732663330346364623061396231653061636164396532643263 +66373364323562363834663432633262316239373131363839343765323138663537613366636165 +65656362636634633265653366633039623330303436386266306464326539376536353632323235 +34356137306139633738336264353430353864656361643430323332663239383766326162623130 +34666334666562313065313661613765636632336161373933393863373135383830353732393834 +35623236633239353737373733363034386230636339623763306637396634663436633531646566 +35333063636232336339383638653530623632396464653466356535366463333662376437306233 +33373266333163643964303333323266643836653231613963376634656664376430376131656363 +37633038376366343536333533396263653265316561306564633262326536323464343037363236 +31366566396333386662313032316535653134323163663537336466643761626536376666376235 +61383565333565353031623539353932303635663234326261333332343239373835646666616263 +37663637323235393063313331306538353166663765613435373833396235343439616663323564 +38393666633630643434353833626638373739663565653636636133623831363066613464393366 +30626130663430373237306230396266306666643061333737373261333562326436303563623332 +62383362393639653738633032353332303539336131343066333432366331633637353135363164 +39393335363534313735626530646662363864656362663438666630626637326638353665343436 +39613935316133393138356638303964613033343435626564626663663831646636386165343164 +36363437363737323931613831653236633632353962306132663663343235646362316438396133 +66386132633039343766373831653235366230666531386334346462663564656165663934356563 +38393736646538633962616664373239303235356432353863633338323839613734343230366234 +61346539636164333463323334633934646661373338643337363061316638393964313363306132 +39643038383532636565666637323632383534393034623164623536663966366261393866303663 +61313262636332616464636664393935633132663565636564363562656133663634623864616263 +39386434326565653735353735333061356131366339363234383566373434386462393566313830 +35613435663332653339643263393765363366343062386663323233383462323964643233376164 +38356565633765396436323862663034343963363937393065353366656665366634303439613333 +30323834353362373438356361656538373032333230326164623665363134373665343631653639 +65353834333562393536323834643134643037303535613430333335663037353030346631303835 +34616537383631343162303062613062643664346163653430363066326162306637303837396662 +38383231336365663635363262643230313037646338646661666335386664663431616630666663 +65326335666630663039313530316138343036356365306235346636303161613437 diff --git a/roles/nginx/tasks/vhosts.yml b/roles/nginx/tasks/vhosts.yml index be71b5a..4528db6 100644 --- a/roles/nginx/tasks/vhosts.yml +++ b/roles/nginx/tasks/vhosts.yml @@ -22,13 +22,13 @@ - name: Install WordPress git: repo=https://github.com/WordPress/WordPress.git dest={{ nginx_root_prefix }}/{{ item.domain_name }}/wordpress version={{ item.wordpress_version }} depth=1 force=yes - when: item.has_wordpress == 'yes' + when: item.has_wordpress == True with_items: "{{ nginx_vhosts }}" tags: wordpress - name: Fix WordPress directory permissions file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory owner=nginx group=nginx recurse=yes - when: item.has_wordpress == 'yes' + when: item.has_wordpress == True with_items: "{{ nginx_vhosts }}" tags: wordpress diff --git a/roles/nginx/templates/https.j2 b/roles/nginx/templates/https.j2 index 88d397b..a0734e9 100644 --- a/roles/nginx/templates/https.j2 +++ b/roles/nginx/templates/https.j2 @@ -1,7 +1,7 @@ {# helper variables and per-site defaults that we can't set in role defaults #} {% set domain_name = item.domain_name %} -{# assume HSTS is off unless a vhost explicitly sets it to "yes" #} -{% set enable_hsts = item.enable_hsts | default("no") %} +{# assume HSTS is off unless a vhost explicitly sets it to True #} +{% set enable_hsts = item.enable_hsts | default(False) %} {# first, check if the current vhost has a custom cert (perhaps self-signed) #} {% if item.tls_certificate_path is defined and item.tls_key_path is defined %} @@ -52,7 +52,7 @@ # of such infrastructure, consider turning off session tickets: ssl_session_tickets off; - {% if enable_hsts == "yes" %} + {% if enable_hsts == True %} # Enable this if you want HSTS (recommended, but be careful) # Include all subdomains and indicate to Google that we want this pre-loaded in Chrome's HSTS store # See: https://hstspreload.appspot.com/ diff --git a/roles/nginx/templates/vhost.conf.j2 b/roles/nginx/templates/vhost.conf.j2 index 239fcc2..0476600 100644 --- a/roles/nginx/templates/vhost.conf.j2 +++ b/roles/nginx/templates/vhost.conf.j2 @@ -3,9 +3,9 @@ {# helper variables and per-site defaults that we can't set in role defaults #} {% set domain_name = item.domain_name %} {% set domain_aliases = item.domain_aliases | default("") %} -{# assume HSTS is off unless a vhost explicitly sets it to "yes" #} -{% set enable_hsts = item.enable_hsts | default("no") %} -{% set has_wordpress = item.has_wordpress | default("no") %} +{# assume HSTS is off unless a vhost explicitly sets it to True #} +{% set enable_hsts = item.enable_hsts | default(False) %} +{% set has_wordpress = item.has_wordpress | default(False) %} # http -> https vhost server { @@ -37,7 +37,7 @@ server { {% include 'https.j2' %} - {% if has_wordpress == "yes" %} + {% if has_wordpress == True %} {% include 'wordpress.j2' %} {% endif %} @@ -78,7 +78,7 @@ server { fastcgi_cache_bypass $http_pragma $wordpress_logged_in; fastcgi_no_cache $http_pragma $wordpress_logged_in; - {% if enable_hsts == "yes" %} + {% if enable_hsts == True %} # Enable this if you want HSTS (recommended, but be careful) # Include all subdomains and indicate to Google that we want this pre-loaded in Chrome's HSTS store # See: https://hstspreload.appspot.com/